Garados007/elm-repono-storage/1.0.0

ReponoStorage

Enables access to the Repono Storage server. These methods and types are simple wrappers over the REST api.

Error

type Error
= HttpError Error
| InvalidPassword
| InvalidToken
| NotFound
| StorageLimitReached
| TokenExhaused

The error states that can happen during the requests.

  • InvalidPassword: An invalid password was provided. This error will also returned if no password was provided if one was expected or a password was provided if none was expected.
  • InvalidToken: The token doesn't meet the criteria. Try to use another one.
  • NotFound: A requested object wasn't found. Maybe it was deleted?
  • StorageLimitReached: This upload cannot be done because this will conflict with the storage limitations. Try to use to delete a file first or use a different container.
  • TokenExhaused: The token can no longer be used for this operation.
  • HttpError: The returned HTTP error cannot be expressed with one of the above.

Container

type alias ContainerId =
String

An alias for the container id. This is used to make the api more readable.

type alias ContainerInfo =
{ id : ContainerId
, created : Posix
, modified : Posix
, encrypted : Bool
, storageLimit : Int
, files : List FileInfo
}

Contains the information about the storage container

= FullInfo ContainerInfo
| EncryptedInfo ContainerId

Contains the information of the container information request.

The variant EncryptedInfo will be used if the container is encrypted and no password was given during the request.

String
-> (Result Error Container -> msg)
-> ContainerId
-> Maybe String
-> Cmd msg

Returns the information of the container.

Expected Errors:

  • InvalidPassword: Invalid password for this container. This will also return if the container is not encrypted and a password was given.
  • NotFound: No container with this id found
String
-> (Result Error ContainerInfo -> msg)
-> TokenId
-> Maybe String
-> Cmd msg

Create a new container which can store a specific amount of data. For this a token has to be provided that has a storage limit.

Expected Errors:

  • InvalidToken: A container cannot be created. This can be the reason of one of the following:
    • The creation token is expired or does not exists
    • The creation token has no specified storage limit
    • The creation token is exhaused and cannot create more container

File

type alias FileId =
String

An alias for the file id. This is used to make the api more readable.

type alias FilePath =
String

An alias for the file path. This is used to make the api more readable.

type alias FileInfo =
{ id : FileId
, path : FilePath
, created : Posix
, modified : Posix
, size : Int
, mime : String
}

Contains the information about a file inside a container

String
-> (Result Error a -> msg)
-> ContainerId
-> FilePath
-> Maybe String
-> Decoder a
-> Cmd msg

Get the binary content of a file.

Expected Errors:

  • InvalidPassword: The password is wrong or not provided (if required).
  • NotFound: The file or container not found.
String
-> (Result Error a -> msg)
-> ContainerId
-> FilePath
-> Maybe String
-> Decoder a
-> Cmd msg

Get the json content of a file.

Expected Errors:

  • InvalidPassword: The password is wrong or not provided (if required).
  • NotFound: The file or container not found.
String
-> (Result Error String -> msg)
-> ContainerId
-> FilePath
-> Maybe String
-> Cmd msg

Get the text content of a file.

Expected Errors:

  • InvalidPassword: The password is wrong or not provided (if required).
  • NotFound: The file or container not found.
String
-> (Result Error () -> msg)
-> ContainerId
-> FilePath
-> Maybe String
-> Body
-> Cmd msg

Replace or upload the new content of a file.

Limitations:

  • The given file path exceed the maximum length of 1024 bytes.
  • The new file size won't make the total size of the container larger than it's maximum allowence.
  • File sizes smaller than 1024 bytes will be counted as they will use 1024 bytes.
  • Each container can have a maximum of 1024 files. After that adding new files to the container is not allowed until some are deleted.

Expected Errors:

  • InvalidPassword: The password is wrong or not provided (if required).
  • NotFound: File not found.
  • StorageLimitReached: Replacing or adding this file will make the container larger than its allowed to be. This code will also returned if the provided path is larger than 1024 bytes.
String
-> (Result Error () -> msg)
-> ContainerId
-> FilePath
-> Maybe String
-> Cmd msg

Deletes a stored file.

Expected Errors:

  • InvalidPassword: The password is wrong or not provided (if required).
  • NotFound: File not found.

Token

type alias TokenId =
String

An alias for the token id. This is used to make the api more readable.

type alias TokenInfo =
{ id : TokenId
, parent : Maybe TokenId
, childTokens : List TokenId
, childContainer : List ContainerId
, storageLimit : Maybe Int
, tokenLimit : Maybe Int
, expired : Bool
, created : Posix
, used : Posix
, hint : Maybe String
}

Contains the information about a token that can be used to create container.

  • id: The id of this token
  • parent: The parent token id
  • childTokens: The direct child tokens
  • childContainer: The container that are created with this token
  • storageLimit: The maximum storage limit for subsequent containers and tokens. If this field is null than this token has an unlimited storage capacity and cannot be used to create containers directly.
  • tokenLimit: The remaining number of tokens that can be created with this one. Only the root token can have an unlimited number of null.
  • expired: States if this token is expired and can be used to create more tokens and containers.
  • created: The creation date of this token.
  • used: The last date this token was used.
  • hint: The hint that was provided durring creation
getToken : String -> (Result Error TokenInfo -> msg) -> TokenId -> Cmd msg

Returns the information of the Token

Expected Errors:

  • NotFound: No token with this id found
String
-> (Result Error TokenInfo -> msg)
-> TokenId
-> Int
-> Int
-> Maybe String
-> Cmd msg

Creates a new token. The new token is a child of the parent token.

Expected Errors:

  • NotFound: No parent token with this id found
  • TokenExhaused: The parent token cannot create a new child token. That can be the reason of:
    • parent token has no remaining tokens to create (token limit is 0).
    • parent token is expired
    • requested storage limit is larger than the storage limit of the header token
    • requested token limit is larger than the token limit of the header token

Report

type alias ReportId =
String

An alias for the report id. This is used to make the api more readable.

type alias Report =
{ reason : String
, files : List FilePath
}

The information of a single report that was submitted.

type alias ReportInfo =
{ id : ReportId
, containerId : ContainerId
, created : Posix
, report : Report
}

The stored meta information including the full report that was submitted.

String
-> (Result Error (List ReportInfo) -> msg)
-> Maybe ContainerId
-> Maybe FilePath
-> Cmd msg

Search for open reports. These reports can be limited to a specific container or file that should be contained.

Expected Errors: none

String
-> (Result Error ReportInfo -> msg)
-> ContainerId
-> Maybe String
-> Report
-> Cmd msg

Creates a new report for a container. This report will be stored and will be checked by a moderator. If a report is accepted the corresponding files or container will be deleted. After a report is solved (successful or not) they will be removed from the list.

If is possible to block creation tokens because of reports.

If the container is password protected it is required to add the correct password. This password will be stored in clear text on the server until the report is resolved.

Expected Errors:

  • InvalidPassword: Invalid password for the container
  • NotFound: Container not found