Safe Haskell | None |
---|---|
Language | Haskell2010 |
This implementation of the git-lfs API uses http Request and Response, but leaves actually connecting up the http client to the user.
You'll want to use a Manager that supports https, since the protocol uses http basic auth.
Some LFS servers, notably Github's, may require a User-Agent header in some of the requests, in order to allow eg, uploads. No such header is added by default, so be sure to add your own.
Synopsis
- data TransferRequest = TransferRequest {}
- data TransferRequestOperation
- data TransferAdapter = Basic
- data TransferRequestObject = TransferRequestObject {}
- startTransferRequest :: Endpoint -> TransferRequest -> Request
- data TransferResponse op = TransferResponse {}
- data TransferResponseOperation op = TransferResponseOperation {}
- class (FromJSON op, ToJSON op) => IsTransferResponseOperation op
- data DownloadOperation = DownloadOperation {}
- data UploadOperation = UploadOperation {}
- data OperationParams = OperationParams {
- href :: Url
- header :: Maybe (Map HTTPHeader HTTPHeaderValue)
- expires_in :: Maybe NumSeconds
- expires_at :: Maybe Text
- data ParsedTransferResponse op
- parseTransferResponse :: IsTransferResponseOperation op => ByteString -> ParsedTransferResponse op
- downloadOperationRequest :: DownloadOperation -> Maybe Request
- uploadOperationRequests :: UploadOperation -> RequestBody -> SHA256 -> Integer -> Maybe [Request]
- data Endpoint
- guessEndpoint :: URI -> Maybe Endpoint
- modifyEndpointRequest :: Endpoint -> (Request -> Request) -> Endpoint
- sshDiscoverEndpointCommand :: FilePath -> TransferRequestOperation -> [String]
- parseSshDiscoverEndpointResponse :: ByteString -> Maybe Endpoint
- data TransferResponseError = TransferResponseError {}
- data TransferResponseObjectError = TransferResponseObjectError {}
- type Url = Text
- type SHA256 = Text
- data GitRef = GitRef {}
- type NumSeconds = Integer
- type HTTPHeader = Text
- type HTTPHeaderValue = Text
Transfer requests
data TransferRequest Source #
Instances
data TransferRequestOperation Source #
Instances
Show TransferRequestOperation Source # | |
Defined in Network.GitLFS showsPrec :: Int -> TransferRequestOperation -> ShowS # show :: TransferRequestOperation -> String # showList :: [TransferRequestOperation] -> ShowS # | |
ToJSON TransferRequestOperation Source # | |
Defined in Network.GitLFS | |
FromJSON TransferRequestOperation Source # | |
Defined in Network.GitLFS |
data TransferAdapter Source #
Instances
Show TransferAdapter Source # | |
Defined in Network.GitLFS showsPrec :: Int -> TransferAdapter -> ShowS # show :: TransferAdapter -> String # showList :: [TransferAdapter] -> ShowS # | |
ToJSON TransferAdapter Source # | |
Defined in Network.GitLFS toJSON :: TransferAdapter -> Value # toEncoding :: TransferAdapter -> Encoding # toJSONList :: [TransferAdapter] -> Value # toEncodingList :: [TransferAdapter] -> Encoding # | |
FromJSON TransferAdapter Source # | |
Defined in Network.GitLFS parseJSON :: Value -> Parser TransferAdapter # parseJSONList :: Value -> Parser [TransferAdapter] # |
data TransferRequestObject Source #
Instances
startTransferRequest :: Endpoint -> TransferRequest -> Request Source #
Makes a Request that will start the process of making a transfer to or from the LFS endpoint.
Responses to transfer requests
data TransferResponse op Source #
Instances
data TransferResponseOperation op Source #
TransferResponseOperation | |
|
Instances
class (FromJSON op, ToJSON op) => IsTransferResponseOperation op Source #
Class of types that can be responses to a transfer request, that contain an operation to use to make the transfer.
Instances
data DownloadOperation Source #
Instances
data UploadOperation Source #
Instances
data OperationParams Source #
OperationParams | |
|
Instances
data ParsedTransferResponse op Source #
parseTransferResponse :: IsTransferResponseOperation op => ByteString -> ParsedTransferResponse op Source #
Parse the body of a response to a transfer request.
Making transfers
downloadOperationRequest :: DownloadOperation -> Maybe Request Source #
Builds a http request to perform a download.
uploadOperationRequests :: UploadOperation -> RequestBody -> SHA256 -> Integer -> Maybe [Request] Source #
Builds http request to perform an upload. The content to upload is provided in the RequestBody, along with its SHA256 and size.
When the LFS server requested verification, there will be a second Request that does that; it should be run only after the upload has succeeded.
When the LFS server already contains the object, an empty list may be returned.
Endpoint discovery
The endpoint of a git-lfs server.
guessEndpoint :: URI -> Maybe Endpoint Source #
Guesses the LFS endpoint from the http url of a git remote.
https://github.com/git-lfs/git-lfs/blob/master/docs/api/server-discovery.md
modifyEndpointRequest :: Endpoint -> (Request -> Request) -> Endpoint Source #
When an Endpoint is used to generate a Request, this allows adjusting that Request.
This can be used to add http basic authentication to an Endpoint:
modifyEndpointRequest (guessEndpoint u) (applyBasicAuth "user" "pass")
sshDiscoverEndpointCommand :: FilePath -> TransferRequestOperation -> [String] Source #
Command to run via ssh with to discover an endpoint. The FilePath is the location of the git repository on the ssh server.
Note that, when sshing to the server, you should take care that the hostname you pass to ssh is really a hostname and not something that ssh will parse an an option, such as -oProxyCommand=".
parseSshDiscoverEndpointResponse :: ByteString -> Maybe Endpoint Source #
Parse the json output when doing ssh endpoint discovery.
Errors
data TransferResponseError Source #
This is an error with a TransferRequest as a whole. It's also possible for a TransferRequest to overall succeed, but fail for some objects; such failures use TransferResponseObjectError.
Instances
data TransferResponseObjectError Source #
An error with a single object within a TransferRequest.
Instances
Show TransferResponseObjectError Source # | |
Defined in Network.GitLFS showsPrec :: Int -> TransferResponseObjectError -> ShowS # show :: TransferResponseObjectError -> String # showList :: [TransferResponseObjectError] -> ShowS # | |
Generic TransferResponseObjectError Source # | |
Defined in Network.GitLFS type Rep TransferResponseObjectError :: Type -> Type # | |
ToJSON TransferResponseObjectError Source # | |
Defined in Network.GitLFS | |
FromJSON TransferResponseObjectError Source # | |
Defined in Network.GitLFS | |
type Rep TransferResponseObjectError Source # | |
Defined in Network.GitLFS type Rep TransferResponseObjectError = D1 ('MetaData "TransferResponseObjectError" "Network.GitLFS" "git-lfs-1.1.2-KawZO12LaU62C1a7jdv4qP" 'False) (C1 ('MetaCons "TransferResponseObjectError" 'PrefixI 'True) (S1 ('MetaSel ('Just "respobjerr_code") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "respobjerr_message") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) |
Additional data types
type NumSeconds = Integer Source #
type HTTPHeader = Text Source #
type HTTPHeaderValue = Text Source #