Openstex v0.3.2 Openstex.Swift.V1.Helpers behaviour

Helper functions for executing more complex multi-step queries for Swift Object Storage.

Summary

Callbacks

Deletes an object from a given container

Deletes an object from a given container

Deletes all objects in a pseudofolder effectively deleting the pseudofolder itself

Helper function to simplify the process of downloading a file. The body of the response contains the binary object (file)

Helper function to simplify the process of downloading a file. Returns the binary object (file) or raises an error. See download_file/3

Gets the swift account string for the swift client

Gets the tempurl key - at an account level

Gets the swift endpoint for a given swift client. Returns the publicUrl of the endpoint with the account string removed

Gets the public url (storage_url) for the swift endpoint

Lists objects within a pseudofolder in a container. see list_objects/3

Lists objects within a pseudofolder in a container. Optionally include objects in nested pseudofolders

Lists all the objects in a container or raises an error. See list_objects/3

Lists objects within a pseudofolder in a container or raises an error. Optionally include objects in nested pseudofolders. see list_objects/3

Lists all pseudofolders including nested pseudofolders in a container. See list_pseudofolders/3

Lists pseudofolders at the top level in a given pseudofolder. See list_pseudofolders/3

Lists all pseudofolders within a pseudofolder in a container

Lists all pseudofolders including nested pseudofolders in a container. See list_pseudofolders!/3

Lists pseudofolders at the top level in a given pseudofolder. See list_pseudofolders!/3

Lists all pseudofolders within a pseudofolder in a container or raises an error. See list_pseudofolders/3

Checks if a pseudofolder exists

Sets the account tempurl key - at an account level

Helper function to simplify the process of uploading a file

Helper function to simplify the process of uploading a file. See upload_file/4. Returns :ok if upload suceeeded or raises and error otherwise

Callbacks

delete_object(server_object, container)
delete_object(server_object :: String.t, container :: String.t) ::
  {:ok, HTTPipe.Conn.t} |
  {:error, HTTPipe.Conn.t}

Deletes an object from a given container

delete_object!(server_object, container)
delete_object!(server_object :: String.t, container :: String.t) ::
  {:ok, HTTPipe.Conn.t} |
  no_return

Deletes an object from a given container

delete_pseudofolder(arg0, arg1)
delete_pseudofolder(String.t, String.t) :: :ok | {:error, list}

Deletes all objects in a pseudofolder effectively deleting the pseudofolder itself.

Arguments

  • pseudofolder: The pseudofolder to be deleted.
  • container: The container in which to delete the pseudofolder.

Notes

  • Returns :ok anyways even if pseudofolder did not exist in the first place.
  • Returns {:error, list} if some objects were not deleted where list represents the objects for which deletion failed.
download_file(arg0, arg1)
download_file(String.t, String.t) ::
  {:ok, Response.t} |
  {:error, Response.t}

Helper function to simplify the process of downloading a file. The body of the response contains the binary object (file).

Arguments

  • server_object: The path of the file on the openstack swift server
  • container: The name of the container.

Example

server_object = "/ex_hubic_tests/nested/test_file.json"
Client.Swift.download_file(server_object, "default", [recv_timeout: (60000 * 1)]) # allow 1 min for download
download_file!(arg0, arg1)
download_file!(String.t, String.t) :: :binary | no_return

Helper function to simplify the process of downloading a file. Returns the binary object (file) or raises an error. See download_file/3.

get_account()
get_account() :: String.t

Gets the swift account string for the swift client

get_account_tempurl_key(keynumber)
get_account_tempurl_key(keynumber :: atom) :: String.t

Gets the tempurl key - at an account level

get_endpoint()
get_endpoint() :: String.t

Gets the swift endpoint for a given swift client. Returns the publicUrl of the endpoint with the account string removed.

get_public_url()
get_public_url() :: String.t

Gets the public url (storage_url) for the swift endpoint

list_objects(arg0)
list_objects(String.t) :: {:ok, list} | {:error, map}

Lists objects within a pseudofolder in a container. see list_objects/3

Arguments

  • container: The name of the container.
list_objects(arg0, arg1, list)
list_objects(String.t, String.t, list) ::
  {:ok, list} |
  {:error, map}

Lists objects within a pseudofolder in a container. Optionally include objects in nested pseudofolders.

Arguments

  • pseudofolder: The pseudofolder in which to list the objects.
  • container: The container in which to find the objects.
  • nested, defaults to :false

    [nested: true] => returns all objects in nested pseudofolders also.

    [nested: false] => returns all objects at the top level and ignores objects witihin nested pseudofolders.

Notes

  • Excludes pseudofolders from the results.
  • If no pseudofolder name is entered, pseudofolder defaults to "", thereby getting all objects in the container
  • Returns the object name.
  • Returns files
  • Does not list pseudofolders

Example

Returns all objects in the "test_folder/" but not objects in nested pseudofolders Client.Swift.listobjects("testfolder/", "default", [nested: :false])

Returns all objects in the "test_folder/" and all nested pseudofolders. Client.Swift.listobjects("testfolder/", "default", [nested: :true])

Returns all objects in the "default" container Client.Swift.list_objects("default", [nested: :true])

list_objects!(arg0)
list_objects!(String.t) :: list | no_return

Lists all the objects in a container or raises an error. See list_objects/3.

list_objects!(arg0, arg1, list)
list_objects!(String.t, String.t, list) ::
  {:ok, list} |
  no_return

Lists objects within a pseudofolder in a container or raises an error. Optionally include objects in nested pseudofolders. see list_objects/3

list_pseudofolders(arg0)
list_pseudofolders(String.t) ::
  {:ok, list} |
  {:error, Openstex.Response.t}

Lists all pseudofolders including nested pseudofolders in a container. See list_pseudofolders/3

Arguments

  • container: The name of the container in which to list the pseudofolders.
list_pseudofolders(arg0, arg1)
list_pseudofolders(String.t, String.t) ::
  {:ok, list} |
  {:error, Openstex.Response.t}

Lists pseudofolders at the top level in a given pseudofolder. See list_pseudofolders/3

Arguments

  • pseudofolder: The pseudofolder in which to search for other top-level pseudofolders
  • container: The name of the container in which to list the pseudofolders.
list_pseudofolders(arg0, arg1, list)
list_pseudofolders(String.t, String.t, list) ::
  {:ok, list} |
  {:error, map}

Lists all pseudofolders within a pseudofolder in a container.

Arguments

  • pseudofolder: The pseudofolder in which to search for other pseudofolders
  • container: The name of the container in which to list the pseudofolders.
  • nested, defaults to :false

    [nested: true] => returns all objects in nested pseudofolders also.

    [nested: false] => returns all objects at the top level and ignores objects witihin nested pseudofolders.

Notes

  • If no pseudofolder is entered, then pseudofolder defaults to "" which in turn results in all pseudofolders being fetched one level deep at the root level.
  • Returns the pseudofolders by name.
  • Traverses as deep as the most nested folder beyond the passed folder to get all folders.
  • Excludes non-pseudofolder objects from the results.

Example

Gets all pseudofolders in the "test_folder/" pseudofolder one level deep (top level) Client.Swift.listpseudofolders("testfolder/", "default")

Gets all pseudofolders in the "test/" pseudofolder one level deep (top level) Client.Swift.list_pseudofolders("test", "default")

Gets all the pseudofolders in the container and traverse to the deepest nested pseudofolders Client.Swift.list_pseudofolders(default", [nested: :true])

list_pseudofolders!(arg0)
list_pseudofolders!(String.t) :: list | no_return

Lists all pseudofolders including nested pseudofolders in a container. See list_pseudofolders!/3

Arguments

  • container: The name of the container in which to list the pseudofolders.
list_pseudofolders!(arg0, arg1)
list_pseudofolders!(String.t, String.t) :: list | no_return

Lists pseudofolders at the top level in a given pseudofolder. See list_pseudofolders!/3

Arguments

  • pseudofolder: The pseudofolder in which to search for other top-level pseudofolders
  • container: The name of the container in which to list the pseudofolders.
list_pseudofolders!(arg0, arg1, list)
list_pseudofolders!(String.t, String.t, list) ::
  list |
  no_return

Lists all pseudofolders within a pseudofolder in a container or raises an error. See list_pseudofolders/3.

pseudofolder_exists?(arg0, arg1)
pseudofolder_exists?(String.t, String.t) ::
  boolean |
  no_return

Checks if a pseudofolder exists.

Arguments

  • pseudofolder: The pseudofolder whose existence is to be checked.
  • container: The name of the container in which to list the pseudofolders.
set_account_temp_url_key(key_number, key)
set_account_temp_url_key(key_number :: atom, key :: String.t) :: :ok

Sets the account tempurl key - at an account level

upload_file(arg0, arg1, arg2, list)
upload_file(String.t, String.t, String.t, list) ::
  {:ok, Response.t} |
  {:error, Response.t}

Helper function to simplify the process of uploading a file.

Arguments

  • file: The path of the file on the client machine.
  • server_object: The path of the file on the openstack swift server
  • container: The name of the container.

Example

file = "/priv/test_file.json"
server_object = "/ex_hubic_tests/nested/test_file.json"
Client.Swift.upload_file(file, server_object, "default")
upload_file!(arg0, arg1, arg2, list)
upload_file!(String.t, String.t, String.t, list) ::
  :ok |
  no_return

Helper function to simplify the process of uploading a file. See upload_file/4. Returns :ok if upload suceeeded or raises and error otherwise.