Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Network.GitLFS
Description
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 -> (ServerSupportsChunks -> RequestBody) -> SHA256 -> Integer -> Maybe [Request]
- newtype ServerSupportsChunks = ServerSupportsChunks Bool
- 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 #
Constructors
TransferRequest | |
Fields |
Instances
data TransferRequestOperation Source #
Constructors
RequestDownload | |
RequestUpload |
Instances
FromJSON TransferRequestOperation Source # | |
Defined in Network.GitLFS Methods parseJSON :: Value -> Parser TransferRequestOperation # parseJSONList :: Value -> Parser [TransferRequestOperation] # | |
ToJSON TransferRequestOperation Source # | |
Defined in Network.GitLFS Methods toJSON :: TransferRequestOperation -> Value # toEncoding :: TransferRequestOperation -> Encoding # toJSONList :: [TransferRequestOperation] -> Value # | |
Show TransferRequestOperation Source # | |
Defined in Network.GitLFS Methods showsPrec :: Int -> TransferRequestOperation -> ShowS # show :: TransferRequestOperation -> String # showList :: [TransferRequestOperation] -> ShowS # |
data TransferAdapter Source #
Constructors
Basic |
Instances
FromJSON TransferAdapter Source # | |
Defined in Network.GitLFS Methods parseJSON :: Value -> Parser TransferAdapter # parseJSONList :: Value -> Parser [TransferAdapter] # | |
ToJSON TransferAdapter Source # | |
Defined in Network.GitLFS Methods toJSON :: TransferAdapter -> Value # toEncoding :: TransferAdapter -> Encoding # toJSONList :: [TransferAdapter] -> Value # toEncodingList :: [TransferAdapter] -> Encoding # omitField :: TransferAdapter -> Bool # | |
Show TransferAdapter Source # | |
Defined in Network.GitLFS Methods showsPrec :: Int -> TransferAdapter -> ShowS # show :: TransferAdapter -> String # showList :: [TransferAdapter] -> ShowS # |
data TransferRequestObject Source #
Constructors
TransferRequestObject | |
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 #
Constructors
TransferResponse | |
Fields
|
Instances
data TransferResponseOperation op Source #
Constructors
TransferResponseOperation | |
Fields
|
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 #
Constructors
DownloadOperation | |
Fields |
Instances
data UploadOperation Source #
Constructors
UploadOperation | |
Fields |
Instances
data OperationParams Source #
Constructors
OperationParams | |
Fields
|
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 -> (ServerSupportsChunks -> RequestBody) -> SHA256 -> Integer -> Maybe [Request] Source #
Builds http request to perform an upload. The content to upload is provided, 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.
newtype ServerSupportsChunks Source #
When the LFS server indicates that it supports Transfer-Encoding chunked, this will contain a true value, and the RequestBody provided to uploadOperationRequests may be created using RequestBodyStreamChunked. Otherwise, that should be avoided as the server may not support the chunked encoding.
Constructors
ServerSupportsChunks Bool |
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.
Constructors
TransferResponseError | |
Fields |
Instances
data TransferResponseObjectError Source #
An error with a single object within a TransferRequest.
Constructors
TransferResponseObjectError | |
Fields |
Instances
Additional data types
type NumSeconds = Integer Source #
type HTTPHeader = Text Source #
type HTTPHeaderValue = Text Source #