View Source Docspring.Connection (docspring v0.0.4)

Handle Tesla connections for Docspring.

Link to this section Summary

Functions

Perform a DELETE request. See request/1 or request/2 for options definition.

Perform a DELETE request. See request/1 or request/2 for options definition.

Perform a DELETE request. See request/1 or request/2 for options definition.

Perform a GET request. See request/1 or request/2 for options definition.

Perform a GET request. See request/1 or request/2 for options definition.

Perform a GET request. See request/1 or request/2 for options definition.

Perform a HEAD request. See request/1 or request/2 for options definition.

Perform a HEAD request. See request/1 or request/2 for options definition.

Perform a HEAD request. See request/1 or request/2 for options definition.

Configure an authless client connection

Configure a client connection using Basic authentication.

Perform a OPTIONS request. See request/1 or request/2 for options definition.

Perform a OPTIONS request. See request/1 or request/2 for options definition.

Perform a OPTIONS request. See request/1 or request/2 for options definition.

Perform a PATCH request. See request/1 or request/2 for options definition.

Perform a PATCH request. See request/1 or request/2 for options definition.

Perform a PATCH request. See request/1 or request/2 for options definition.

Perform a POST request. See request/1 or request/2 for options definition.

Perform a POST request. See request/1 or request/2 for options definition.

Perform a POST request. See request/1 or request/2 for options definition.

Perform a PUT request. See request/1 or request/2 for options definition.

Perform a PUT request. See request/1 or request/2 for options definition.

Perform a PUT request. See request/1 or request/2 for options definition.

Perform a request. See request/2 for available options.

Perform a request using client function

Perform a TRACE request. See request/1 or request/2 for options definition.

Perform a TRACE request. See request/1 or request/2 for options definition.

Perform a TRACE request. See request/1 or request/2 for options definition.

Link to this section Types

@type option() ::
  {:method, Tesla.Env.method()}
  | {:url, Tesla.Env.url()}
  | {:query, Tesla.Env.query()}
  | {:headers, Tesla.Env.headers()}
  | {:body, Tesla.Env.body()}
  | {:opts, Tesla.Env.opts()}

Link to this section Functions

@spec delete(Tesla.Env.url()) :: Tesla.Env.t()

Perform a DELETE request. See request/1 or request/2 for options definition.

Example

ExampleApi.delete("/users")
@spec delete(Tesla.Env.client(), Tesla.Env.url()) :: Tesla.Env.t()
@spec delete(Tesla.Env.url(), [option()]) :: Tesla.Env.t()

Perform a DELETE request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.delete("/users")
ExampleApi.delete("/users", query: [page: 1])
Link to this function

delete(client, url, options)

View Source
@spec delete(Tesla.Env.client(), Tesla.Env.url(), [option()]) :: Tesla.Env.t()

Perform a DELETE request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.delete("/users", query: [page: 1])
@spec get(Tesla.Env.url()) :: Tesla.Env.t()

Perform a GET request. See request/1 or request/2 for options definition.

Example

ExampleApi.get("/users")
@spec get(Tesla.Env.client(), Tesla.Env.url()) :: Tesla.Env.t()
@spec get(Tesla.Env.url(), [option()]) :: Tesla.Env.t()

Perform a GET request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.get("/users")
ExampleApi.get("/users", query: [page: 1])
Link to this function

get(client, url, options)

View Source
@spec get(Tesla.Env.client(), Tesla.Env.url(), [option()]) :: Tesla.Env.t()

Perform a GET request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.get("/users", query: [page: 1])
@spec head(Tesla.Env.url()) :: Tesla.Env.t()

Perform a HEAD request. See request/1 or request/2 for options definition.

Example

ExampleApi.head("/users")
@spec head(Tesla.Env.client(), Tesla.Env.url()) :: Tesla.Env.t()
@spec head(Tesla.Env.url(), [option()]) :: Tesla.Env.t()

Perform a HEAD request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.head("/users")
ExampleApi.head("/users", query: [page: 1])
Link to this function

head(client, url, options)

View Source
@spec head(Tesla.Env.client(), Tesla.Env.url(), [option()]) :: Tesla.Env.t()

Perform a HEAD request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.head("/users", query: [page: 1])
@spec new() :: Tesla.Env.client()

Configure an authless client connection

Returns

Tesla.Env.client

@spec new(String.t(), String.t()) :: Tesla.Env.client()

Configure a client connection using Basic authentication.

parameters

Parameters

  • username (String): Username used for authentication
  • password (String): Password used for authentication

Returns

Tesla.Env.client

@spec options(Tesla.Env.url()) :: Tesla.Env.t()

Perform a OPTIONS request. See request/1 or request/2 for options definition.

Example

ExampleApi.options("/users")
@spec options(Tesla.Env.client(), Tesla.Env.url()) :: Tesla.Env.t()
@spec options(Tesla.Env.url(), [option()]) :: Tesla.Env.t()

Perform a OPTIONS request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.options("/users")
ExampleApi.options("/users", query: [page: 1])
Link to this function

options(client, url, options)

View Source
@spec options(Tesla.Env.client(), Tesla.Env.url(), [option()]) :: Tesla.Env.t()

Perform a OPTIONS request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.options("/users", query: [page: 1])
@spec patch(Tesla.Env.url(), Tesla.Env.body()) :: Tesla.Env.t()

Perform a PATCH request. See request/1 or request/2 for options definition.

Example

ExampleApi.patch("/users", %{name: "Jon"})
Link to this function

patch(client, url, body)

View Source

Perform a PATCH request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.patch("/users", %{name: "Jon"})
ExampleApi.patch("/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function

patch(client, url, body, options)

View Source

Perform a PATCH request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.patch("/users", %{name: "Jon"}, query: [scope: "admin"])
@spec post(Tesla.Env.url(), Tesla.Env.body()) :: Tesla.Env.t()

Perform a POST request. See request/1 or request/2 for options definition.

Example

ExampleApi.post("/users", %{name: "Jon"})

Perform a POST request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.post("/users", %{name: "Jon"})
ExampleApi.post("/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function

post(client, url, body, options)

View Source

Perform a POST request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.post("/users", %{name: "Jon"}, query: [scope: "admin"])

Perform a PUT request. See request/1 or request/2 for options definition.

Example

ExampleApi.put("/users", %{name: "Jon"})

Perform a PUT request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.put("/users", %{name: "Jon"})
ExampleApi.put("/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function

put(client, url, body, options)

View Source

Perform a PUT request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.put("/users", %{name: "Jon"}, query: [scope: "admin"])
@spec request([option()]) :: Tesla.Env.t()

Perform a request. See request/2 for available options.

Link to this function

request(client, options)

View Source
@spec request(Tesla.Env.client(), [option()]) :: Tesla.Env.t()

Perform a request using client function

Options:

  • :method - the request method, one of [:head, :get, :delete, :trace, :options, :post, :put, :patch]
  • :url - either full url e.g. "http://example.com/some/path" or just "/some/path" if using Tesla.Middleware.BaseUrl
  • :query - a keyword list of query params, e.g. [page: 1, per_page: 100]
  • :headers - a keyworld list of headers, e.g. [{"content-type", "text/plain"}]
  • :body - depends on used middleware:
    • by default it can be a binary
    • if using e.g. JSON encoding middleware it can be a nested map
    • if adapter supports it it can be a Stream with any of the above
  • :opts - custom, per-request middleware or adapter options

Examples:

ExampleApi.request(method: :get, url: "/users/path")

You can also use shortcut methods like:

ExampleApi.get("/users/1")

or

myclient |> ExampleApi.post("/users", %{name: "Jon"})
@spec trace(Tesla.Env.url()) :: Tesla.Env.t()

Perform a TRACE request. See request/1 or request/2 for options definition.

Example

ExampleApi.trace("/users")
@spec trace(Tesla.Env.client(), Tesla.Env.url()) :: Tesla.Env.t()
@spec trace(Tesla.Env.url(), [option()]) :: Tesla.Env.t()

Perform a TRACE request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.trace("/users")
ExampleApi.trace("/users", query: [page: 1])
Link to this function

trace(client, url, options)

View Source
@spec trace(Tesla.Env.client(), Tesla.Env.url(), [option()]) :: Tesla.Env.t()

Perform a TRACE request. See request/1 or request/2 for options definition.

Example

myclient |> ExampleApi.trace("/users", query: [page: 1])