module Ecluse.Core.Registry (
RegistryResponse (..),
MirrorArtifact (..),
firstHashValue,
ParseError (..),
FetchFault (..),
PublishError (..),
PublishFault (..),
UrlFormationError (..),
PublishRelayResponse (..),
PublishRelayFault (..),
) where
import Ecluse.Core.Fault (TransportFault)
import Ecluse.Core.Package (Hash, HashAlg, hashAlg, hashValue)
import Ecluse.Core.Security (LimitError)
newtype RegistryResponse = RegistryResponse
{ RegistryResponse -> ByteString
responseBody :: ByteString
}
deriving stock (RegistryResponse -> RegistryResponse -> Bool
(RegistryResponse -> RegistryResponse -> Bool)
-> (RegistryResponse -> RegistryResponse -> Bool)
-> Eq RegistryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RegistryResponse -> RegistryResponse -> Bool
== :: RegistryResponse -> RegistryResponse -> Bool
$c/= :: RegistryResponse -> RegistryResponse -> Bool
/= :: RegistryResponse -> RegistryResponse -> Bool
Eq, Int -> RegistryResponse -> ShowS
[RegistryResponse] -> ShowS
RegistryResponse -> String
(Int -> RegistryResponse -> ShowS)
-> (RegistryResponse -> String)
-> ([RegistryResponse] -> ShowS)
-> Show RegistryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RegistryResponse -> ShowS
showsPrec :: Int -> RegistryResponse -> ShowS
$cshow :: RegistryResponse -> String
show :: RegistryResponse -> String
$cshowList :: [RegistryResponse] -> ShowS
showList :: [RegistryResponse] -> ShowS
Show)
data MirrorArtifact = MirrorArtifact
{ MirrorArtifact -> Text
maFilename :: Text
, MirrorArtifact -> NonEmpty Hash
maHashes :: NonEmpty Hash
, MirrorArtifact -> Maybe Int
maSize :: Maybe Int
}
deriving stock (MirrorArtifact -> MirrorArtifact -> Bool
(MirrorArtifact -> MirrorArtifact -> Bool)
-> (MirrorArtifact -> MirrorArtifact -> Bool) -> Eq MirrorArtifact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MirrorArtifact -> MirrorArtifact -> Bool
== :: MirrorArtifact -> MirrorArtifact -> Bool
$c/= :: MirrorArtifact -> MirrorArtifact -> Bool
/= :: MirrorArtifact -> MirrorArtifact -> Bool
Eq, Int -> MirrorArtifact -> ShowS
[MirrorArtifact] -> ShowS
MirrorArtifact -> String
(Int -> MirrorArtifact -> ShowS)
-> (MirrorArtifact -> String)
-> ([MirrorArtifact] -> ShowS)
-> Show MirrorArtifact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MirrorArtifact -> ShowS
showsPrec :: Int -> MirrorArtifact -> ShowS
$cshow :: MirrorArtifact -> String
show :: MirrorArtifact -> String
$cshowList :: [MirrorArtifact] -> ShowS
showList :: [MirrorArtifact] -> ShowS
Show)
firstHashValue :: HashAlg -> MirrorArtifact -> Maybe Text
firstHashValue :: HashAlg -> MirrorArtifact -> Maybe Text
firstHashValue HashAlg
alg MirrorArtifact
artifact =
(Hash -> Text) -> Maybe Hash -> Maybe Text
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Hash -> Text
hashValue ((Hash -> Bool) -> NonEmpty Hash -> Maybe Hash
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find ((HashAlg -> HashAlg -> Bool
forall a. Eq a => a -> a -> Bool
== HashAlg
alg) (HashAlg -> Bool) -> (Hash -> HashAlg) -> Hash -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash -> HashAlg
hashAlg) (MirrorArtifact -> NonEmpty Hash
maHashes MirrorArtifact
artifact))
newtype ParseError = ParseError
{ ParseError -> Text
parseErrorMessage :: Text
}
deriving stock (ParseError -> ParseError -> Bool
(ParseError -> ParseError -> Bool)
-> (ParseError -> ParseError -> Bool) -> Eq ParseError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ParseError -> ParseError -> Bool
== :: ParseError -> ParseError -> Bool
$c/= :: ParseError -> ParseError -> Bool
/= :: ParseError -> ParseError -> Bool
Eq, Int -> ParseError -> ShowS
[ParseError] -> ShowS
ParseError -> String
(Int -> ParseError -> ShowS)
-> (ParseError -> String)
-> ([ParseError] -> ShowS)
-> Show ParseError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ParseError -> ShowS
showsPrec :: Int -> ParseError -> ShowS
$cshow :: ParseError -> String
show :: ParseError -> String
$cshowList :: [ParseError] -> ShowS
showList :: [ParseError] -> ShowS
Show)
newtype PublishError = PublishError
{ PublishError -> Text
publishErrorMessage :: Text
}
deriving stock (PublishError -> PublishError -> Bool
(PublishError -> PublishError -> Bool)
-> (PublishError -> PublishError -> Bool) -> Eq PublishError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PublishError -> PublishError -> Bool
== :: PublishError -> PublishError -> Bool
$c/= :: PublishError -> PublishError -> Bool
/= :: PublishError -> PublishError -> Bool
Eq, Int -> PublishError -> ShowS
[PublishError] -> ShowS
PublishError -> String
(Int -> PublishError -> ShowS)
-> (PublishError -> String)
-> ([PublishError] -> ShowS)
-> Show PublishError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PublishError -> ShowS
showsPrec :: Int -> PublishError -> ShowS
$cshow :: PublishError -> String
show :: PublishError -> String
$cshowList :: [PublishError] -> ShowS
showList :: [PublishError] -> ShowS
Show)
data UrlFormationError
=
EmptyBaseUrl
|
UnparseableUrl Text
deriving stock (UrlFormationError -> UrlFormationError -> Bool
(UrlFormationError -> UrlFormationError -> Bool)
-> (UrlFormationError -> UrlFormationError -> Bool)
-> Eq UrlFormationError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UrlFormationError -> UrlFormationError -> Bool
== :: UrlFormationError -> UrlFormationError -> Bool
$c/= :: UrlFormationError -> UrlFormationError -> Bool
/= :: UrlFormationError -> UrlFormationError -> Bool
Eq, Int -> UrlFormationError -> ShowS
[UrlFormationError] -> ShowS
UrlFormationError -> String
(Int -> UrlFormationError -> ShowS)
-> (UrlFormationError -> String)
-> ([UrlFormationError] -> ShowS)
-> Show UrlFormationError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UrlFormationError -> ShowS
showsPrec :: Int -> UrlFormationError -> ShowS
$cshow :: UrlFormationError -> String
show :: UrlFormationError -> String
$cshowList :: [UrlFormationError] -> ShowS
showList :: [UrlFormationError] -> ShowS
Show)
data FetchFault
=
FetchUrlUnformable UrlFormationError
|
FetchBoundExceeded LimitError
|
FetchTransport TransportFault
deriving stock (FetchFault -> FetchFault -> Bool
(FetchFault -> FetchFault -> Bool)
-> (FetchFault -> FetchFault -> Bool) -> Eq FetchFault
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FetchFault -> FetchFault -> Bool
== :: FetchFault -> FetchFault -> Bool
$c/= :: FetchFault -> FetchFault -> Bool
/= :: FetchFault -> FetchFault -> Bool
Eq, Int -> FetchFault -> ShowS
[FetchFault] -> ShowS
FetchFault -> String
(Int -> FetchFault -> ShowS)
-> (FetchFault -> String)
-> ([FetchFault] -> ShowS)
-> Show FetchFault
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FetchFault -> ShowS
showsPrec :: Int -> FetchFault -> ShowS
$cshow :: FetchFault -> String
show :: FetchFault -> String
$cshowList :: [FetchFault] -> ShowS
showList :: [FetchFault] -> ShowS
Show)
data PublishRelayFault
=
RelayUrlUnformable UrlFormationError
|
RelayTransport TransportFault
|
RelayBoundExceeded LimitError
deriving stock (PublishRelayFault -> PublishRelayFault -> Bool
(PublishRelayFault -> PublishRelayFault -> Bool)
-> (PublishRelayFault -> PublishRelayFault -> Bool)
-> Eq PublishRelayFault
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PublishRelayFault -> PublishRelayFault -> Bool
== :: PublishRelayFault -> PublishRelayFault -> Bool
$c/= :: PublishRelayFault -> PublishRelayFault -> Bool
/= :: PublishRelayFault -> PublishRelayFault -> Bool
Eq, Int -> PublishRelayFault -> ShowS
[PublishRelayFault] -> ShowS
PublishRelayFault -> String
(Int -> PublishRelayFault -> ShowS)
-> (PublishRelayFault -> String)
-> ([PublishRelayFault] -> ShowS)
-> Show PublishRelayFault
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PublishRelayFault -> ShowS
showsPrec :: Int -> PublishRelayFault -> ShowS
$cshow :: PublishRelayFault -> String
show :: PublishRelayFault -> String
$cshowList :: [PublishRelayFault] -> ShowS
showList :: [PublishRelayFault] -> ShowS
Show)
data PublishRelayResponse = PublishRelayResponse
{ PublishRelayResponse -> Int
relayStatus :: Int
, PublishRelayResponse -> LByteString
relayBody :: LByteString
}
deriving stock (PublishRelayResponse -> PublishRelayResponse -> Bool
(PublishRelayResponse -> PublishRelayResponse -> Bool)
-> (PublishRelayResponse -> PublishRelayResponse -> Bool)
-> Eq PublishRelayResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PublishRelayResponse -> PublishRelayResponse -> Bool
== :: PublishRelayResponse -> PublishRelayResponse -> Bool
$c/= :: PublishRelayResponse -> PublishRelayResponse -> Bool
/= :: PublishRelayResponse -> PublishRelayResponse -> Bool
Eq, Int -> PublishRelayResponse -> ShowS
[PublishRelayResponse] -> ShowS
PublishRelayResponse -> String
(Int -> PublishRelayResponse -> ShowS)
-> (PublishRelayResponse -> String)
-> ([PublishRelayResponse] -> ShowS)
-> Show PublishRelayResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PublishRelayResponse -> ShowS
showsPrec :: Int -> PublishRelayResponse -> ShowS
$cshow :: PublishRelayResponse -> String
show :: PublishRelayResponse -> String
$cshowList :: [PublishRelayResponse] -> ShowS
showList :: [PublishRelayResponse] -> ShowS
Show)
data PublishFault
=
PublishUrlUnformable UrlFormationError
|
PublishRejected PublishError
|
PublishTransport TransportFault
deriving stock (PublishFault -> PublishFault -> Bool
(PublishFault -> PublishFault -> Bool)
-> (PublishFault -> PublishFault -> Bool) -> Eq PublishFault
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PublishFault -> PublishFault -> Bool
== :: PublishFault -> PublishFault -> Bool
$c/= :: PublishFault -> PublishFault -> Bool
/= :: PublishFault -> PublishFault -> Bool
Eq, Int -> PublishFault -> ShowS
[PublishFault] -> ShowS
PublishFault -> String
(Int -> PublishFault -> ShowS)
-> (PublishFault -> String)
-> ([PublishFault] -> ShowS)
-> Show PublishFault
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PublishFault -> ShowS
showsPrec :: Int -> PublishFault -> ShowS
$cshow :: PublishFault -> String
show :: PublishFault -> String
$cshowList :: [PublishFault] -> ShowS
showList :: [PublishFault] -> ShowS
Show)