- mkConfig :: Locale -> String -> String -> AccessType -> IO Config
- data Config = Config {}
- data CertVerifier = CertVerifier {
- certVerifierName :: String
- certVerifierFunc :: CertVerifierFunc
- certVerifierInsecure :: CertVerifier
- certVerifierFromPemFile :: FilePath -> IO (Either ErrorMessage CertVerifier)
- certVerifierFromRootCerts :: [X509] -> Ascii -> [X509] -> IO TLSCertificateUsage
- data AppId = AppId String String
- data Hosts = Hosts {}
- hostsDefault :: Hosts
- data Locale
- localeEn :: Locale
- localeEs :: Locale
- localeFr :: Locale
- localeDe :: Locale
- localeJp :: Locale
- data AccessType
- type Manager = Manager
- withManager :: (Manager -> IO r) -> IO r
- data RequestToken = RequestToken String String
- authStart :: Manager -> Config -> Maybe URL -> IO (Either ErrorMessage (RequestToken, URL))
- data AccessToken = AccessToken String String
- authFinish :: Manager -> Config -> RequestToken -> IO (Either ErrorMessage (AccessToken, String))
- data Session = Session {}
- getAccountInfo :: Manager -> Session -> IO (Either ErrorMessage AccountInfo)
- data AccountInfo = AccountInfo {}
- getMetadata :: Manager -> Session -> Path -> IO (Either ErrorMessage Meta)
- getMetadataWithChildren :: Manager -> Session -> Path -> Maybe Integer -> IO (Either ErrorMessage (Meta, Maybe FolderContents))
- getMetadataWithChildrenIfChanged :: Manager -> Session -> Path -> Maybe Integer -> FolderHash -> IO (Either ErrorMessage (Maybe (Meta, Maybe FolderContents)))
- data Meta = Meta MetaBase MetaExtra
- data MetaBase = MetaBase {
- metaRoot :: AccessType
- metaPath :: String
- metaIsDeleted :: Bool
- metaThumbnail :: Bool
- metaIcon :: String
- data MetaExtra
- data FolderContents = FolderContents {
- folderHash :: FolderHash
- folderChildren :: [Meta]
- data FileExtra = FileExtra {}
- newtype FolderHash = FolderHash String
- newtype FileRevision = FileRevision String
- addFile :: Manager -> Session -> Path -> RequestBody -> IO (Either ErrorMessage Meta)
- forceFile :: Manager -> Session -> Path -> RequestBody -> IO (Either ErrorMessage Meta)
- updateFile :: Manager -> Session -> Path -> RequestBody -> FileRevision -> IO (Either ErrorMessage Meta)
- fileRevisionToString :: FileRevision -> String
- folderHashToString :: FolderHash -> String
- type ErrorMessage = String
- type URL = String
- type Path = String
- data RequestBody
- bsRequestBody :: ByteString -> RequestBody
Configuration
A convenience function that constructs a Config
The configuration used to make authentication calls and API calls. You typically create
one of these via the config
helper function.
Config | |
|
data CertVerifier Source
How the server's SSL certificate will be verified.
CertVerifier | |
|
certVerifierInsecure :: CertVerifierSource
A dummy implementation that doesn't perform any verification.
certVerifierFromPemFile :: FilePath -> IO (Either ErrorMessage CertVerifier)Source
Reads certificates in PEM format from the given file and uses those as the roots when
verifying certificates. This function basically just loads the certificates and delegates
to certVerifierFromRootCerts
for the actual checking.
certVerifierFromRootCertsSource
:: [X509] | The set of trusted root certificates. |
-> Ascii | The remove server's domain name. |
-> [X509] | The certificate chain provided by the remote server. |
-> IO TLSCertificateUsage |
Given a set of root certificates, yields a certificate validation function.
Your application's Dropbox app key and app secret.
The set of hosts that serve the Dropbox API. Just use hostsDefault
.
The standard set of hosts that serve the Dropbox API. Used to create a Config
.
data AccessType Source
The type of folder access your Dropbox application uses (https://www.dropbox.com/developers/start/core).
AccessTypeDropbox | Full access to the user's entire Dropbox |
AccessTypeAppFolder | Access to an application-specific app folder within the user's Dropbox |
Manager
withManager :: (Manager -> IO r) -> IO rSource
OAuth
data RequestToken Source
An OAuth request token (returned by authStart
)
:: Manager | The HTTP connection manager to use. |
-> Config | |
-> Maybe URL | The callback URL (optional) |
-> IO (Either ErrorMessage (RequestToken, URL)) |
OAuth step 1. If successful, returns a RequestToken
(to be used with
authFinish
eventually) and an authorization URL that you should redirect the user
to next. If you provide a callback URL (optional), then the authorization URL you
send the user to will redirect to your callback URL after the user authorizes your
application.
data AccessToken Source
An OAuth request token (returned by authFinish
, used to construct a Session
)
:: Manager | The HTTP connection manager to use. |
-> Config | |
-> RequestToken | The |
-> IO (Either ErrorMessage (AccessToken, String)) | The |
OAuth step 3. Once you've directed the user to the authorization URL from authStart
and the user has authorized your app, call this function to get a RequestToken
, which
is used to make Dropbox API calls.
Contains a Config
and an AccessToken
. Every API call (after OAuth is complete)
requires this as an argument.
Session | |
|
Get user account info
:: Manager | The HTTP connection manager to use. |
-> Session | |
-> IO (Either ErrorMessage AccountInfo) |
Retrieve information about the user account your AccessToken
is connected to.
data AccountInfo Source
Information about a user account.
AccountInfo | |
|
Basic file access API
Get metadata
:: Manager | The HTTP connection manager to use. |
-> Session | |
-> Path | The full path (relative to your |
-> IO (Either ErrorMessage Meta) |
Get the metadata for the file or folder at the given path.
:: Manager | The HTTP connection manager to use. |
-> Session | |
-> Path | The full path (relative to your |
-> Maybe Integer | A limit on folder contents (max: 10,000). If the path refers to a folder and this folder
has more than the specified number of immediate children, the entire
|
-> IO (Either ErrorMessage (Meta, Maybe FolderContents)) |
Get the metadata for the file or folder at the given path. If it's a folder, return the first-level folder contents' metadata entries as well.
getMetadataWithChildrenIfChangedSource
:: Manager | The HTTP connection manager to use. |
-> Session | |
-> Path | |
-> Maybe Integer | |
-> FolderHash | For folders, the returned child metadata will include a |
-> IO (Either ErrorMessage (Maybe (Meta, Maybe FolderContents))) |
Same as getMetadataWithChildren
except it'll return Nothing
if the FolderHash
of the folder on Dropbox is the same as the FolderHash
passed in.
Metadata common to both files and folders.
MetaBase | |
|
Metadata that's specific to either files or folders.
data FolderContents Source
The single-level contents of a folder.
FolderContents | |
|
Extra metadata specific to files (and not folders)
FileExtra | |
|
newtype FolderHash Source
Represents an identifier for a folder's metadata and contents. Can be used with
getMetadataWithChildrenIfChanged
to avoid downloading a folder's metadata and contents
if it hasn't changed.
newtype FileRevision Source
Represents a file's revision (fileRevision
).
Uploading files
:: Manager | The HTTP connection manager to use. |
-> Session | |
-> Path | The full path (relative to your |
-> RequestBody | The file contents. |
-> IO (Either ErrorMessage Meta) |
Add a new file. If a file or folder already exists at the given path, your file will be automatically renamed. If successful, you'll get back the metadata for your newly-uploaded file.
:: Manager | The |
-> Session | |
-> Path | The full path (relative to your |
-> RequestBody | The file contents. |
-> IO (Either ErrorMessage Meta) |
Add a file. If a file already exists at the given path, that file will be overwritten. If successful, you'll get back the metadata for your newly-uploaded file.
:: Manager | The HTTP connection manager to use. |
-> Session | |
-> Path | The full path (relative to your |
-> RequestBody | The file contents. |
-> FileRevision | The revision of the file you expect to be writing to. |
-> IO (Either ErrorMessage Meta) |
Overwrite a file, assuming it is the version you expect. Specify the version
you expect with the FileRevision
. If the file on Dropbox matches the given
revision, the file will be replaced with the contents you specify. If the file
on Dropbox doesn't have the specified revision, it will be left alone and your
file will be automatically renamed. If successful, you'll get back the metadata
for your newly-uploaded file.
Common data types
type ErrorMessage = StringSource
data RequestBody Source
An HTTP request body: an Int64
for the length and an Enumerator
that yields the actual data.
bsRequestBody :: ByteString -> RequestBodySource
Create a RequestBody
from a single ByteString