ExHubic v0.1.0 ExHubic.Services.V1.Query

Helper functions for building queries for the hubic api.

Example

ExHubic.Services.V1.Query.scope() |> ExHubic.request!()

Summary

Functions

Get the account object properties

Returns used space & quota of your account

Deletes a public url to a file

Get detailed information for an object at a given uri

Get all links as a list of links (showing the object internal uri - not the indirectUri)

Get all published objects' public urls with detailed info

Returns openstack credentials for connecting to the file API

Get the possible scopes for hubic API

Functions

account()

Specs

account :: ExHubic.Query.t

Get the account object properties.

Api

GET /account

Example

ExHubic.Services.V1.Query.account() |> ExHubic.request()

Doctest

iex> ExHubic.Services.V1.Query.account()
%ExHubic.Query{method: :get, params: %{}, service: :hubic,  uri: "/account"}
account_usage()

Specs

account_usage :: ExHubic.Query.t

Returns used space & quota of your account.

Api

GET /account/usage

Example

ExHubic.Services.V1.Query.account_usage() |> ExHubic.request!()

Doctest

iex> ExHubic.Services.V1.Query.account_usage()
%ExHubic.Query{method: :get, uri: "/account/usage", params: %{}}
delete_link(server_object)

Specs

delete_link(String.t) :: ExHubic.Query.t

Deletes a public url to a file

Api

DELETE /account/links/{uri}

Example:

import ExHubic.Services.V1.Query, only: [delete_link: 1]
container = "new_container"
object = "server_file.txt"
folder = "/"
uri = folder <> object
query = delete_link(uri)
ExHubic.request(query)

Doctest

iex> ExHubic.Services.V1.Query.delete_link("/test_folder/test_file.txt")
%ExHubic.Query{method: :delete, params: %{}, service: :hubic,
 uri: "/account/links/%2Ftest_folder%2Ftest_file.txt"}
get_link(server_object)

Specs

get_link(String.t) :: ExHubic.Query.t

Get detailed information for an object at a given uri.

Api

GET /account/links/{uri}

Example

import ExHubic.Services.V1.Query, only: [get_link: 1]
container = "new_container"
folder = "/"
object = "server_file.txt"
uri = folder <> object
query = get_link(uri)
ExHubic.request(query)

Doctest

iex> ExHubic.Services.V1.Query.get_link("test")
%ExHubic.Query{method: :get, uri: "/account/links/%2Ftest", params: %{}}
get_links()

Specs

get_links :: ExHubic.Query.t

Get all links as a list of links (showing the object internal uri - not the indirectUri).

Api

GET /account/links

Example

ExHubic.Services.V1.Query.get_links() |> ExHubic.request!()

Doctest

iex> ExHubic.Services.V1.Query.get_links()
%ExHubic.Query{method: :get, uri: "/account/links", params: %{}}
openstack_credentials()

Specs

openstack_credentials :: ExHubic.Query.t

Returns openstack credentials for connecting to the file API.

Api

GET /account/credentials

Example

ExHubic.Services.V1.Query.openstack_credentials() |> ExHubic.request!()

Doctest

iex> ExHubic.Services.V1.Query.openstack_credentials()
%ExHubic.Query{method: :get, uri: "/account/credentials", params: %{}}
publish_object(container, server_object, opts \\ [])

Specs

publish_object(String.t, String.t, Keyword.t) :: ExHubic.Query.t

Create a public url to a file.

Api

POST /account/links

Arguments

  • folder: the psuedofolder to which the file has been saved in the container. defaults to "/".
  • ttl: time in days for which the link will remain public. Note: Ovh only allow a maximum ttl of 30 days after the link is automatically inactivated. The ttl can be 1,5,10,15,20,25 or 30. See hubic faq under What is sharing? for more information. defaults to 5.
  • file: this is the type of object being created. can be a "file" or "folder". defaults to "file".

Example:

import ExHubic.Services.V1.Query, only: [publish_object: 3]
container = "new_container"
object = "server_file.txt"
query = publish_object(container, object, folder: "/")
{:ok, resp} = ExHubic.request(query)
%{ "indirectUrl" => link_indirect_uri, "expirationDate" => exp,
   "creationDate" => created_on, "uri" => uri } = resp.body

Notes:

  • The indirectUrl seems to redirect the user to a temp url (signed url).

Doctest:

iex> ExHubic.Services.V1.Query.publish_object("test_container", "test_file.txt")
%ExHubic.Query{headers: [], method: :post,
params: %{binary: "{\"uri\":\"/test_file.txt\",\"type\":\"file\",\"ttl\":\"5\",\"mode\":\"ro\",\"container\":\"test_container\",\"comment\":\"none\"}"},
service: :hubic, uri: "/account/links"}
scope()

Specs

scope :: ExHubic.Query.t

Get the possible scopes for hubic API.

Api

GET /scope/scope,

Example

ExHubic.Services.V1.Query.scope() |> ExHubic.request!()

Doctest

iex> ExHubic.Services.V1.Query.scope()
%ExHubic.Query{method: :get, params: %{}, service: :hubic, uri: "/scope/scope"}