Garados007 / elm-repono-storage / ReponoStorage

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

Error


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

The error states that can happen during the requests.

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 : Time.Posix
, modified : Time.Posix
, encrypted : Basics.Bool
, storageLimit : Basics.Int
, files : List FileInfo 
}

Contains the information about the storage container


type 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.

getContainer : String -> (Result Error Container -> msg) -> ContainerId -> Maybe String -> Platform.Cmd.Cmd msg

Returns the information of the container.

Expected Errors:

newContainer : String -> (Result Error ContainerInfo -> msg) -> TokenId -> Maybe String -> Platform.Cmd.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:

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 : Time.Posix
, modified : Time.Posix
, size : Basics.Int
, mime : String 
}

Contains the information about a file inside a container

getFile : String -> (Result Error a -> msg) -> ContainerId -> FilePath -> Maybe String -> Bytes.Decode.Decoder a -> Platform.Cmd.Cmd msg

Get the binary content of a file.

Expected Errors:

getFileJson : String -> (Result Error a -> msg) -> ContainerId -> FilePath -> Maybe String -> Json.Decode.Decoder a -> Platform.Cmd.Cmd msg

Get the json content of a file.

Expected Errors:

getFileString : String -> (Result Error String -> msg) -> ContainerId -> FilePath -> Maybe String -> Platform.Cmd.Cmd msg

Get the text content of a file.

Expected Errors:

putFile : String -> (Result Error () -> msg) -> ContainerId -> FilePath -> Maybe String -> Http.Body -> Platform.Cmd.Cmd msg

Replace or upload the new content of a file.

Limitations:

Expected Errors:

deleteFile : String -> (Result Error () -> msg) -> ContainerId -> FilePath -> Maybe String -> Platform.Cmd.Cmd msg

Deletes a stored file.

Expected Errors:

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 Basics.Int
, tokenLimit : Maybe Basics.Int
, expired : Basics.Bool
, created : Time.Posix
, used : Time.Posix
, hint : Maybe String 
}

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

getToken : String -> (Result Error TokenInfo -> msg) -> TokenId -> Platform.Cmd.Cmd msg

Returns the information of the Token

Expected Errors:

newToken : String -> (Result Error TokenInfo -> msg) -> TokenId -> Basics.Int -> Basics.Int -> Maybe String -> Platform.Cmd.Cmd msg

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

Expected Errors:

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 : Time.Posix
, report : Report 
}

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

getReports : String -> (Result Error (List ReportInfo) -> msg) -> Maybe ContainerId -> Maybe FilePath -> Platform.Cmd.Cmd msg

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

Expected Errors: none

postReport : String -> (Result Error ReportInfo -> msg) -> ContainerId -> Maybe String -> Report -> Platform.Cmd.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: