git-lfs-1.2.2: git-lfs protocol
Safe HaskellNone
LanguageHaskell2010

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

Transfer requests

data TransferRequest #

Instances

Instances details
FromJSON TransferRequest # 
Instance details

Defined in Network.GitLFS

ToJSON TransferRequest # 
Instance details

Defined in Network.GitLFS

Generic TransferRequest # 
Instance details

Defined in Network.GitLFS

Associated Types

type Rep TransferRequest 
Instance details

Defined in Network.GitLFS

type Rep TransferRequest = D1 ('MetaData "TransferRequest" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "TransferRequest" 'PrefixI 'True) ((S1 ('MetaSel ('Just "req_operation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TransferRequestOperation) :*: S1 ('MetaSel ('Just "req_transfers") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TransferAdapter])) :*: (S1 ('MetaSel ('Just "req_ref") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe GitRef)) :*: S1 ('MetaSel ('Just "req_objects") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TransferRequestObject]))))
Show TransferRequest # 
Instance details

Defined in Network.GitLFS

type Rep TransferRequest # 
Instance details

Defined in Network.GitLFS

type Rep TransferRequest = D1 ('MetaData "TransferRequest" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "TransferRequest" 'PrefixI 'True) ((S1 ('MetaSel ('Just "req_operation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TransferRequestOperation) :*: S1 ('MetaSel ('Just "req_transfers") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TransferAdapter])) :*: (S1 ('MetaSel ('Just "req_ref") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe GitRef)) :*: S1 ('MetaSel ('Just "req_objects") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TransferRequestObject]))))

data TransferRequestObject #

Instances

Instances details
FromJSON TransferRequestObject # 
Instance details

Defined in Network.GitLFS

ToJSON TransferRequestObject # 
Instance details

Defined in Network.GitLFS

Generic TransferRequestObject # 
Instance details

Defined in Network.GitLFS

Associated Types

type Rep TransferRequestObject 
Instance details

Defined in Network.GitLFS

type Rep TransferRequestObject = D1 ('MetaData "TransferRequestObject" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "TransferRequestObject" 'PrefixI 'True) (S1 ('MetaSel ('Just "req_oid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SHA256) :*: S1 ('MetaSel ('Just "req_size") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer)))
Show TransferRequestObject # 
Instance details

Defined in Network.GitLFS

type Rep TransferRequestObject # 
Instance details

Defined in Network.GitLFS

type Rep TransferRequestObject = D1 ('MetaData "TransferRequestObject" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "TransferRequestObject" 'PrefixI 'True) (S1 ('MetaSel ('Just "req_oid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SHA256) :*: S1 ('MetaSel ('Just "req_size") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer)))

startTransferRequest :: Endpoint -> TransferRequest -> Request #

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 #

Instances

Instances details
IsTransferResponseOperation op => FromJSON (TransferResponse op) # 
Instance details

Defined in Network.GitLFS

IsTransferResponseOperation op => ToJSON (TransferResponse op) # 
Instance details

Defined in Network.GitLFS

Generic (TransferResponse op) # 
Instance details

Defined in Network.GitLFS

Associated Types

type Rep (TransferResponse op) 
Instance details

Defined in Network.GitLFS

type Rep (TransferResponse op) = D1 ('MetaData "TransferResponse" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "TransferResponse" 'PrefixI 'True) (S1 ('MetaSel ('Just "transfer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe TransferAdapter)) :*: S1 ('MetaSel ('Just "objects") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TransferResponseOperation op])))
Show op => Show (TransferResponse op) # 
Instance details

Defined in Network.GitLFS

type Rep (TransferResponse op) # 
Instance details

Defined in Network.GitLFS

type Rep (TransferResponse op) = D1 ('MetaData "TransferResponse" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "TransferResponse" 'PrefixI 'True) (S1 ('MetaSel ('Just "transfer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe TransferAdapter)) :*: S1 ('MetaSel ('Just "objects") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TransferResponseOperation op])))

data TransferResponseOperation op #

Instances

Instances details
FromJSON op => FromJSON (TransferResponseOperation op) # 
Instance details

Defined in Network.GitLFS

ToJSON op => ToJSON (TransferResponseOperation op) # 
Instance details

Defined in Network.GitLFS

Generic (TransferResponseOperation op) # 
Instance details

Defined in Network.GitLFS

Associated Types

type Rep (TransferResponseOperation op) 
Instance details

Defined in Network.GitLFS

type Rep (TransferResponseOperation op) = D1 ('MetaData "TransferResponseOperation" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "TransferResponseOperation" 'PrefixI 'True) ((S1 ('MetaSel ('Just "resp_oid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SHA256) :*: S1 ('MetaSel ('Just "resp_size") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer)) :*: (S1 ('MetaSel ('Just "resp_authenticated") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Bool)) :*: (S1 ('MetaSel ('Just "resp_actions") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe op)) :*: S1 ('MetaSel ('Just "resp_error") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe TransferResponseObjectError))))))
Show op => Show (TransferResponseOperation op) # 
Instance details

Defined in Network.GitLFS

type Rep (TransferResponseOperation op) # 
Instance details

Defined in Network.GitLFS

type Rep (TransferResponseOperation op) = D1 ('MetaData "TransferResponseOperation" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "TransferResponseOperation" 'PrefixI 'True) ((S1 ('MetaSel ('Just "resp_oid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SHA256) :*: S1 ('MetaSel ('Just "resp_size") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer)) :*: (S1 ('MetaSel ('Just "resp_authenticated") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Bool)) :*: (S1 ('MetaSel ('Just "resp_actions") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe op)) :*: S1 ('MetaSel ('Just "resp_error") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe TransferResponseObjectError))))))

class (FromJSON op, ToJSON op) => IsTransferResponseOperation op #

Class of types that can be responses to a transfer request, that contain an operation to use to make the transfer.

Instances

Instances details
IsTransferResponseOperation DownloadOperation # 
Instance details

Defined in Network.GitLFS

IsTransferResponseOperation UploadOperation # 
Instance details

Defined in Network.GitLFS

data DownloadOperation #

Instances

Instances details
FromJSON DownloadOperation # 
Instance details

Defined in Network.GitLFS

ToJSON DownloadOperation # 
Instance details

Defined in Network.GitLFS

Generic DownloadOperation # 
Instance details

Defined in Network.GitLFS

Associated Types

type Rep DownloadOperation 
Instance details

Defined in Network.GitLFS

type Rep DownloadOperation = D1 ('MetaData "DownloadOperation" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "DownloadOperation" 'PrefixI 'True) (S1 ('MetaSel ('Just "download") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 OperationParams)))
Show DownloadOperation # 
Instance details

Defined in Network.GitLFS

IsTransferResponseOperation DownloadOperation # 
Instance details

Defined in Network.GitLFS

type Rep DownloadOperation # 
Instance details

Defined in Network.GitLFS

type Rep DownloadOperation = D1 ('MetaData "DownloadOperation" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "DownloadOperation" 'PrefixI 'True) (S1 ('MetaSel ('Just "download") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 OperationParams)))

data UploadOperation #

Instances

Instances details
FromJSON UploadOperation # 
Instance details

Defined in Network.GitLFS

ToJSON UploadOperation # 
Instance details

Defined in Network.GitLFS

Generic UploadOperation # 
Instance details

Defined in Network.GitLFS

Associated Types

type Rep UploadOperation 
Instance details

Defined in Network.GitLFS

type Rep UploadOperation = D1 ('MetaData "UploadOperation" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "UploadOperation" 'PrefixI 'True) (S1 ('MetaSel ('Just "upload") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 OperationParams) :*: S1 ('MetaSel ('Just "verify") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe OperationParams))))
Show UploadOperation # 
Instance details

Defined in Network.GitLFS

IsTransferResponseOperation UploadOperation # 
Instance details

Defined in Network.GitLFS

type Rep UploadOperation # 
Instance details

Defined in Network.GitLFS

type Rep UploadOperation = D1 ('MetaData "UploadOperation" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "UploadOperation" 'PrefixI 'True) (S1 ('MetaSel ('Just "upload") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 OperationParams) :*: S1 ('MetaSel ('Just "verify") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe OperationParams))))

data OperationParams #

Instances

Instances details
FromJSON OperationParams # 
Instance details

Defined in Network.GitLFS

ToJSON OperationParams # 
Instance details

Defined in Network.GitLFS

Generic OperationParams # 
Instance details

Defined in Network.GitLFS

Associated Types

type Rep OperationParams 
Instance details

Defined in Network.GitLFS

type Rep OperationParams = D1 ('MetaData "OperationParams" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "OperationParams" 'PrefixI 'True) ((S1 ('MetaSel ('Just "href") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Url) :*: S1 ('MetaSel ('Just "header") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Map HTTPHeader HTTPHeaderValue)))) :*: (S1 ('MetaSel ('Just "expires_in") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe NumSeconds)) :*: S1 ('MetaSel ('Just "expires_at") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)))))
Show OperationParams # 
Instance details

Defined in Network.GitLFS

type Rep OperationParams # 
Instance details

Defined in Network.GitLFS

type Rep OperationParams = D1 ('MetaData "OperationParams" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "OperationParams" 'PrefixI 'True) ((S1 ('MetaSel ('Just "href") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Url) :*: S1 ('MetaSel ('Just "header") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Map HTTPHeader HTTPHeaderValue)))) :*: (S1 ('MetaSel ('Just "expires_in") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe NumSeconds)) :*: S1 ('MetaSel ('Just "expires_at") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)))))

parseTransferResponse :: IsTransferResponseOperation op => ByteString -> ParsedTransferResponse op #

Parse the body of a response to a transfer request.

Making transfers

downloadOperationRequest :: DownloadOperation -> Maybe Request #

Builds a http request to perform a download.

uploadOperationRequests :: UploadOperation -> (ServerSupportsChunks -> RequestBody) -> SHA256 -> Integer -> Maybe [Request] #

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 #

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.

Endpoint discovery

data Endpoint #

The endpoint of a git-lfs server.

Instances

Instances details
Show Endpoint # 
Instance details

Defined in Network.GitLFS

modifyEndpointRequest :: Endpoint -> (Request -> Request) -> Endpoint #

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] #

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 #

Parse the json output when doing ssh endpoint discovery.

Errors

data TransferResponseError #

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

Instances details
FromJSON TransferResponseError # 
Instance details

Defined in Network.GitLFS

ToJSON TransferResponseError # 
Instance details

Defined in Network.GitLFS

Generic TransferResponseError # 
Instance details

Defined in Network.GitLFS

Associated Types

type Rep TransferResponseError 
Instance details

Defined in Network.GitLFS

type Rep TransferResponseError = D1 ('MetaData "TransferResponseError" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "TransferResponseError" 'PrefixI 'True) (S1 ('MetaSel ('Just "resperr_message") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: (S1 ('MetaSel ('Just "resperr_request_id") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "resperr_documentation_url") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Url)))))
Show TransferResponseError # 
Instance details

Defined in Network.GitLFS

type Rep TransferResponseError # 
Instance details

Defined in Network.GitLFS

type Rep TransferResponseError = D1 ('MetaData "TransferResponseError" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "TransferResponseError" 'PrefixI 'True) (S1 ('MetaSel ('Just "resperr_message") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: (S1 ('MetaSel ('Just "resperr_request_id") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "resperr_documentation_url") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Url)))))

data TransferResponseObjectError #

An error with a single object within a TransferRequest.

Instances

Instances details
FromJSON TransferResponseObjectError # 
Instance details

Defined in Network.GitLFS

ToJSON TransferResponseObjectError # 
Instance details

Defined in Network.GitLFS

Generic TransferResponseObjectError # 
Instance details

Defined in Network.GitLFS

Associated Types

type Rep TransferResponseObjectError 
Instance details

Defined in Network.GitLFS

type Rep TransferResponseObjectError = D1 ('MetaData "TransferResponseObjectError" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" '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)))
Show TransferResponseObjectError # 
Instance details

Defined in Network.GitLFS

type Rep TransferResponseObjectError # 
Instance details

Defined in Network.GitLFS

type Rep TransferResponseObjectError = D1 ('MetaData "TransferResponseObjectError" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" '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 Url = Text #

type SHA256 = Text #

data GitRef #

Constructors

GitRef 

Fields

Instances

Instances details
FromJSON GitRef # 
Instance details

Defined in Network.GitLFS

ToJSON GitRef # 
Instance details

Defined in Network.GitLFS

Generic GitRef # 
Instance details

Defined in Network.GitLFS

Associated Types

type Rep GitRef 
Instance details

Defined in Network.GitLFS

type Rep GitRef = D1 ('MetaData "GitRef" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "GitRef" 'PrefixI 'True) (S1 ('MetaSel ('Just "name") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

Methods

from :: GitRef -> Rep GitRef x #

to :: Rep GitRef x -> GitRef #

Show GitRef # 
Instance details

Defined in Network.GitLFS

type Rep GitRef # 
Instance details

Defined in Network.GitLFS

type Rep GitRef = D1 ('MetaData "GitRef" "Network.GitLFS" "git-lfs-1.2.2-HYmgwzzFuiP5ggm5eFdJzj" 'False) (C1 ('MetaCons "GitRef" 'PrefixI 'True) (S1 ('MetaSel ('Just "name") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))