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 :: String.t, container :: String.t) :: {:ok, HTTPipe.Conn.t} | {:error, HTTPipe.Conn.t}
Deletes an object from a given container
delete_object!(server_object :: String.t, container :: String.t) :: {:ok, HTTPipe.Conn.t} | no_return
Deletes an object from a given container
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 wherelist
represents the objects for which deletion failed.
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 servercontainer
: 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
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
Arguments
container
: The name of the container.
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])
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
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.
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 pseudofolderscontainer
: The name of the container in which to list the pseudofolders.
Lists all pseudofolders within a pseudofolder in a container.
Arguments
pseudofolder
: The pseudofolder in which to search for other pseudofolderscontainer
: 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])
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.
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 pseudofolderscontainer
: The name of the container in which to list the pseudofolders.
Lists all pseudofolders within a pseudofolder in a container or raises an error. See list_pseudofolders/3
.
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 :: atom, key :: String.t) :: :ok
Sets the account tempurl key - at an account level
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 servercontainer
: 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")