{-# LANGUAGE DisambiguateRecordFields #-}

-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2022 Wire Swiss GmbH <opensource@wire.com>
--
-- This program is free software: you can redistribute it and/or modify it under
-- the terms of the GNU Affero General Public License as published by the Free
-- Software Foundation, either version 3 of the License, or (at your option) any
-- later version.
--
-- This program is distributed in the hope that it will be useful, but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
-- details.
--
-- You should have received a copy of the GNU Affero General Public License along
-- with this program. If not, see <https://www.gnu.org/licenses/>.

module Wire.API.Routes.Internal.Brig.Connection where

import Data.Aeson (FromJSON, ToJSON)
import Data.Id
import Data.OpenApi qualified as S
import Data.Qualified
import Data.Schema
import Imports
import Wire.API.Connection

data ConnectionsStatusRequest = ConnectionsStatusRequest
  { ConnectionsStatusRequest -> [UserId]
csrFrom :: ![UserId],
    ConnectionsStatusRequest -> Maybe [UserId]
csrTo :: !(Maybe [UserId])
  }
  deriving (ConnectionsStatusRequest -> ConnectionsStatusRequest -> Bool
(ConnectionsStatusRequest -> ConnectionsStatusRequest -> Bool)
-> (ConnectionsStatusRequest -> ConnectionsStatusRequest -> Bool)
-> Eq ConnectionsStatusRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConnectionsStatusRequest -> ConnectionsStatusRequest -> Bool
== :: ConnectionsStatusRequest -> ConnectionsStatusRequest -> Bool
$c/= :: ConnectionsStatusRequest -> ConnectionsStatusRequest -> Bool
/= :: ConnectionsStatusRequest -> ConnectionsStatusRequest -> Bool
Eq, Int -> ConnectionsStatusRequest -> ShowS
[ConnectionsStatusRequest] -> ShowS
ConnectionsStatusRequest -> String
(Int -> ConnectionsStatusRequest -> ShowS)
-> (ConnectionsStatusRequest -> String)
-> ([ConnectionsStatusRequest] -> ShowS)
-> Show ConnectionsStatusRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConnectionsStatusRequest -> ShowS
showsPrec :: Int -> ConnectionsStatusRequest -> ShowS
$cshow :: ConnectionsStatusRequest -> String
show :: ConnectionsStatusRequest -> String
$cshowList :: [ConnectionsStatusRequest] -> ShowS
showList :: [ConnectionsStatusRequest] -> ShowS
Show, (forall x.
 ConnectionsStatusRequest -> Rep ConnectionsStatusRequest x)
-> (forall x.
    Rep ConnectionsStatusRequest x -> ConnectionsStatusRequest)
-> Generic ConnectionsStatusRequest
forall x.
Rep ConnectionsStatusRequest x -> ConnectionsStatusRequest
forall x.
ConnectionsStatusRequest -> Rep ConnectionsStatusRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
ConnectionsStatusRequest -> Rep ConnectionsStatusRequest x
from :: forall x.
ConnectionsStatusRequest -> Rep ConnectionsStatusRequest x
$cto :: forall x.
Rep ConnectionsStatusRequest x -> ConnectionsStatusRequest
to :: forall x.
Rep ConnectionsStatusRequest x -> ConnectionsStatusRequest
Generic)
  deriving ([ConnectionsStatusRequest] -> Value
[ConnectionsStatusRequest] -> Encoding
ConnectionsStatusRequest -> Value
ConnectionsStatusRequest -> Encoding
(ConnectionsStatusRequest -> Value)
-> (ConnectionsStatusRequest -> Encoding)
-> ([ConnectionsStatusRequest] -> Value)
-> ([ConnectionsStatusRequest] -> Encoding)
-> ToJSON ConnectionsStatusRequest
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: ConnectionsStatusRequest -> Value
toJSON :: ConnectionsStatusRequest -> Value
$ctoEncoding :: ConnectionsStatusRequest -> Encoding
toEncoding :: ConnectionsStatusRequest -> Encoding
$ctoJSONList :: [ConnectionsStatusRequest] -> Value
toJSONList :: [ConnectionsStatusRequest] -> Value
$ctoEncodingList :: [ConnectionsStatusRequest] -> Encoding
toEncodingList :: [ConnectionsStatusRequest] -> Encoding
ToJSON, Value -> Parser [ConnectionsStatusRequest]
Value -> Parser ConnectionsStatusRequest
(Value -> Parser ConnectionsStatusRequest)
-> (Value -> Parser [ConnectionsStatusRequest])
-> FromJSON ConnectionsStatusRequest
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser ConnectionsStatusRequest
parseJSON :: Value -> Parser ConnectionsStatusRequest
$cparseJSONList :: Value -> Parser [ConnectionsStatusRequest]
parseJSONList :: Value -> Parser [ConnectionsStatusRequest]
FromJSON, Typeable ConnectionsStatusRequest
Typeable ConnectionsStatusRequest =>
(Proxy ConnectionsStatusRequest
 -> Declare (Definitions Schema) NamedSchema)
-> ToSchema ConnectionsStatusRequest
Proxy ConnectionsStatusRequest
-> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a =>
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy ConnectionsStatusRequest
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy ConnectionsStatusRequest
-> Declare (Definitions Schema) NamedSchema
S.ToSchema) via (Schema ConnectionsStatusRequest)

instance ToSchema ConnectionsStatusRequest where
  schema :: ValueSchema NamedSwaggerDoc ConnectionsStatusRequest
schema =
    Text
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionsStatusRequest
     ConnectionsStatusRequest
-> ValueSchema NamedSwaggerDoc ConnectionsStatusRequest
forall doc doc' a b.
HasObject doc doc' =>
Text
-> SchemaP doc Object [Pair] a b -> SchemaP doc' Value Value a b
object Text
"ConnectionsStatusRequest" (SchemaP
   SwaggerDoc
   Object
   [Pair]
   ConnectionsStatusRequest
   ConnectionsStatusRequest
 -> ValueSchema NamedSwaggerDoc ConnectionsStatusRequest)
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionsStatusRequest
     ConnectionsStatusRequest
-> ValueSchema NamedSwaggerDoc ConnectionsStatusRequest
forall a b. (a -> b) -> a -> b
$
      [UserId] -> Maybe [UserId] -> ConnectionsStatusRequest
ConnectionsStatusRequest
        ([UserId] -> Maybe [UserId] -> ConnectionsStatusRequest)
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionsStatusRequest [UserId]
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionsStatusRequest
     (Maybe [UserId] -> ConnectionsStatusRequest)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConnectionsStatusRequest -> [UserId]
csrFrom (ConnectionsStatusRequest -> [UserId])
-> SchemaP SwaggerDoc Object [Pair] [UserId] [UserId]
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionsStatusRequest [UserId]
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> SchemaP SwaggerDoc Value Value [UserId] [UserId]
-> SchemaP SwaggerDoc Object [Pair] [UserId] [UserId]
forall doc' doc a b.
HasField doc' doc =>
Text
-> SchemaP doc' Value Value a b -> SchemaP doc Object [Pair] a b
field Text
"from" (ValueSchema NamedSwaggerDoc UserId
-> SchemaP SwaggerDoc Value Value [UserId] [UserId]
forall ndoc doc a.
(HasArray ndoc doc, HasName ndoc) =>
ValueSchema ndoc a -> ValueSchema doc [a]
array ValueSchema NamedSwaggerDoc UserId
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema)
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  ConnectionsStatusRequest
  (Maybe [UserId] -> ConnectionsStatusRequest)
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionsStatusRequest (Maybe [UserId])
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionsStatusRequest
     ConnectionsStatusRequest
forall a b.
SchemaP SwaggerDoc Object [Pair] ConnectionsStatusRequest (a -> b)
-> SchemaP SwaggerDoc Object [Pair] ConnectionsStatusRequest a
-> SchemaP SwaggerDoc Object [Pair] ConnectionsStatusRequest b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConnectionsStatusRequest -> Maybe [UserId]
csrTo (ConnectionsStatusRequest -> Maybe [UserId])
-> SchemaP
     SwaggerDoc Object [Pair] (Maybe [UserId]) (Maybe [UserId])
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionsStatusRequest (Maybe [UserId])
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= SchemaP SwaggerDoc Object [Pair] [UserId] (Maybe [UserId])
-> SchemaP
     SwaggerDoc Object [Pair] (Maybe [UserId]) (Maybe [UserId])
forall w d v a b.
Monoid w =>
SchemaP d v w a b -> SchemaP d v w (Maybe a) b
maybe_ (Text
-> SchemaP SwaggerDoc Value Value [UserId] [UserId]
-> SchemaP SwaggerDoc Object [Pair] [UserId] (Maybe [UserId])
forall doc doc' a b.
(HasOpt doc, HasField doc' doc) =>
Text
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a (Maybe b)
optField Text
"to" (ValueSchema NamedSwaggerDoc UserId
-> SchemaP SwaggerDoc Value Value [UserId] [UserId]
forall ndoc doc a.
(HasArray ndoc doc, HasName ndoc) =>
ValueSchema ndoc a -> ValueSchema doc [a]
array ValueSchema NamedSwaggerDoc UserId
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema))

data ConnectionsStatusRequestV2 = ConnectionsStatusRequestV2
  { ConnectionsStatusRequestV2 -> [UserId]
csrv2From :: ![UserId],
    ConnectionsStatusRequestV2 -> Maybe [Qualified UserId]
csrv2To :: !(Maybe [Qualified UserId]),
    ConnectionsStatusRequestV2 -> Maybe Relation
csrv2Relation :: !(Maybe Relation)
  }
  deriving (ConnectionsStatusRequestV2 -> ConnectionsStatusRequestV2 -> Bool
(ConnectionsStatusRequestV2 -> ConnectionsStatusRequestV2 -> Bool)
-> (ConnectionsStatusRequestV2
    -> ConnectionsStatusRequestV2 -> Bool)
-> Eq ConnectionsStatusRequestV2
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConnectionsStatusRequestV2 -> ConnectionsStatusRequestV2 -> Bool
== :: ConnectionsStatusRequestV2 -> ConnectionsStatusRequestV2 -> Bool
$c/= :: ConnectionsStatusRequestV2 -> ConnectionsStatusRequestV2 -> Bool
/= :: ConnectionsStatusRequestV2 -> ConnectionsStatusRequestV2 -> Bool
Eq, Int -> ConnectionsStatusRequestV2 -> ShowS
[ConnectionsStatusRequestV2] -> ShowS
ConnectionsStatusRequestV2 -> String
(Int -> ConnectionsStatusRequestV2 -> ShowS)
-> (ConnectionsStatusRequestV2 -> String)
-> ([ConnectionsStatusRequestV2] -> ShowS)
-> Show ConnectionsStatusRequestV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConnectionsStatusRequestV2 -> ShowS
showsPrec :: Int -> ConnectionsStatusRequestV2 -> ShowS
$cshow :: ConnectionsStatusRequestV2 -> String
show :: ConnectionsStatusRequestV2 -> String
$cshowList :: [ConnectionsStatusRequestV2] -> ShowS
showList :: [ConnectionsStatusRequestV2] -> ShowS
Show, (forall x.
 ConnectionsStatusRequestV2 -> Rep ConnectionsStatusRequestV2 x)
-> (forall x.
    Rep ConnectionsStatusRequestV2 x -> ConnectionsStatusRequestV2)
-> Generic ConnectionsStatusRequestV2
forall x.
Rep ConnectionsStatusRequestV2 x -> ConnectionsStatusRequestV2
forall x.
ConnectionsStatusRequestV2 -> Rep ConnectionsStatusRequestV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
ConnectionsStatusRequestV2 -> Rep ConnectionsStatusRequestV2 x
from :: forall x.
ConnectionsStatusRequestV2 -> Rep ConnectionsStatusRequestV2 x
$cto :: forall x.
Rep ConnectionsStatusRequestV2 x -> ConnectionsStatusRequestV2
to :: forall x.
Rep ConnectionsStatusRequestV2 x -> ConnectionsStatusRequestV2
Generic)
  deriving ([ConnectionsStatusRequestV2] -> Value
[ConnectionsStatusRequestV2] -> Encoding
ConnectionsStatusRequestV2 -> Value
ConnectionsStatusRequestV2 -> Encoding
(ConnectionsStatusRequestV2 -> Value)
-> (ConnectionsStatusRequestV2 -> Encoding)
-> ([ConnectionsStatusRequestV2] -> Value)
-> ([ConnectionsStatusRequestV2] -> Encoding)
-> ToJSON ConnectionsStatusRequestV2
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: ConnectionsStatusRequestV2 -> Value
toJSON :: ConnectionsStatusRequestV2 -> Value
$ctoEncoding :: ConnectionsStatusRequestV2 -> Encoding
toEncoding :: ConnectionsStatusRequestV2 -> Encoding
$ctoJSONList :: [ConnectionsStatusRequestV2] -> Value
toJSONList :: [ConnectionsStatusRequestV2] -> Value
$ctoEncodingList :: [ConnectionsStatusRequestV2] -> Encoding
toEncodingList :: [ConnectionsStatusRequestV2] -> Encoding
ToJSON, Value -> Parser [ConnectionsStatusRequestV2]
Value -> Parser ConnectionsStatusRequestV2
(Value -> Parser ConnectionsStatusRequestV2)
-> (Value -> Parser [ConnectionsStatusRequestV2])
-> FromJSON ConnectionsStatusRequestV2
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser ConnectionsStatusRequestV2
parseJSON :: Value -> Parser ConnectionsStatusRequestV2
$cparseJSONList :: Value -> Parser [ConnectionsStatusRequestV2]
parseJSONList :: Value -> Parser [ConnectionsStatusRequestV2]
FromJSON, Typeable ConnectionsStatusRequestV2
Typeable ConnectionsStatusRequestV2 =>
(Proxy ConnectionsStatusRequestV2
 -> Declare (Definitions Schema) NamedSchema)
-> ToSchema ConnectionsStatusRequestV2
Proxy ConnectionsStatusRequestV2
-> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a =>
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy ConnectionsStatusRequestV2
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy ConnectionsStatusRequestV2
-> Declare (Definitions Schema) NamedSchema
S.ToSchema) via (Schema ConnectionsStatusRequestV2)

instance ToSchema ConnectionsStatusRequestV2 where
  schema :: ValueSchema NamedSwaggerDoc ConnectionsStatusRequestV2
schema =
    Text
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionsStatusRequestV2
     ConnectionsStatusRequestV2
-> ValueSchema NamedSwaggerDoc ConnectionsStatusRequestV2
forall doc doc' a b.
HasObject doc doc' =>
Text
-> SchemaP doc Object [Pair] a b -> SchemaP doc' Value Value a b
object Text
"ConnectionsStatusRequestV2" (SchemaP
   SwaggerDoc
   Object
   [Pair]
   ConnectionsStatusRequestV2
   ConnectionsStatusRequestV2
 -> ValueSchema NamedSwaggerDoc ConnectionsStatusRequestV2)
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionsStatusRequestV2
     ConnectionsStatusRequestV2
-> ValueSchema NamedSwaggerDoc ConnectionsStatusRequestV2
forall a b. (a -> b) -> a -> b
$
      [UserId]
-> Maybe [Qualified UserId]
-> Maybe Relation
-> ConnectionsStatusRequestV2
ConnectionsStatusRequestV2
        ([UserId]
 -> Maybe [Qualified UserId]
 -> Maybe Relation
 -> ConnectionsStatusRequestV2)
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionsStatusRequestV2 [UserId]
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionsStatusRequestV2
     (Maybe [Qualified UserId]
      -> Maybe Relation -> ConnectionsStatusRequestV2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConnectionsStatusRequestV2 -> [UserId]
csrv2From (ConnectionsStatusRequestV2 -> [UserId])
-> SchemaP SwaggerDoc Object [Pair] [UserId] [UserId]
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionsStatusRequestV2 [UserId]
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> SchemaP SwaggerDoc Value Value [UserId] [UserId]
-> SchemaP SwaggerDoc Object [Pair] [UserId] [UserId]
forall doc' doc a b.
HasField doc' doc =>
Text
-> SchemaP doc' Value Value a b -> SchemaP doc Object [Pair] a b
field Text
"from" (ValueSchema NamedSwaggerDoc UserId
-> SchemaP SwaggerDoc Value Value [UserId] [UserId]
forall ndoc doc a.
(HasArray ndoc doc, HasName ndoc) =>
ValueSchema ndoc a -> ValueSchema doc [a]
array ValueSchema NamedSwaggerDoc UserId
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema)
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  ConnectionsStatusRequestV2
  (Maybe [Qualified UserId]
   -> Maybe Relation -> ConnectionsStatusRequestV2)
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionsStatusRequestV2
     (Maybe [Qualified UserId])
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionsStatusRequestV2
     (Maybe Relation -> ConnectionsStatusRequestV2)
forall a b.
SchemaP
  SwaggerDoc Object [Pair] ConnectionsStatusRequestV2 (a -> b)
-> SchemaP SwaggerDoc Object [Pair] ConnectionsStatusRequestV2 a
-> SchemaP SwaggerDoc Object [Pair] ConnectionsStatusRequestV2 b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConnectionsStatusRequestV2 -> Maybe [Qualified UserId]
csrv2To (ConnectionsStatusRequestV2 -> Maybe [Qualified UserId])
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     (Maybe [Qualified UserId])
     (Maybe [Qualified UserId])
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionsStatusRequestV2
     (Maybe [Qualified UserId])
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= SchemaP
  SwaggerDoc
  Object
  [Pair]
  [Qualified UserId]
  (Maybe [Qualified UserId])
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     (Maybe [Qualified UserId])
     (Maybe [Qualified UserId])
forall w d v a b.
Monoid w =>
SchemaP d v w a b -> SchemaP d v w (Maybe a) b
maybe_ (Text
-> SchemaP
     SwaggerDoc Value Value [Qualified UserId] [Qualified UserId]
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     [Qualified UserId]
     (Maybe [Qualified UserId])
forall doc doc' a b.
(HasOpt doc, HasField doc' doc) =>
Text
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a (Maybe b)
optField Text
"to" (ValueSchema NamedSwaggerDoc (Qualified UserId)
-> SchemaP
     SwaggerDoc Value Value [Qualified UserId] [Qualified UserId]
forall ndoc doc a.
(HasArray ndoc doc, HasName ndoc) =>
ValueSchema ndoc a -> ValueSchema doc [a]
array ValueSchema NamedSwaggerDoc (Qualified UserId)
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema))
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  ConnectionsStatusRequestV2
  (Maybe Relation -> ConnectionsStatusRequestV2)
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionsStatusRequestV2
     (Maybe Relation)
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionsStatusRequestV2
     ConnectionsStatusRequestV2
forall a b.
SchemaP
  SwaggerDoc Object [Pair] ConnectionsStatusRequestV2 (a -> b)
-> SchemaP SwaggerDoc Object [Pair] ConnectionsStatusRequestV2 a
-> SchemaP SwaggerDoc Object [Pair] ConnectionsStatusRequestV2 b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConnectionsStatusRequestV2 -> Maybe Relation
csrv2Relation (ConnectionsStatusRequestV2 -> Maybe Relation)
-> SchemaP
     SwaggerDoc Object [Pair] (Maybe Relation) (Maybe Relation)
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionsStatusRequestV2
     (Maybe Relation)
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= SchemaP SwaggerDoc Object [Pair] Relation (Maybe Relation)
-> SchemaP
     SwaggerDoc Object [Pair] (Maybe Relation) (Maybe Relation)
forall w d v a b.
Monoid w =>
SchemaP d v w a b -> SchemaP d v w (Maybe a) b
maybe_ (Text
-> SchemaP NamedSwaggerDoc Value Value Relation Relation
-> SchemaP SwaggerDoc Object [Pair] Relation (Maybe Relation)
forall doc doc' a b.
(HasOpt doc, HasField doc' doc) =>
Text
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a (Maybe b)
optField Text
"relation" SchemaP NamedSwaggerDoc Value Value Relation Relation
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema)

data ConnectionStatus = ConnectionStatus
  { ConnectionStatus -> UserId
csFrom :: !UserId,
    ConnectionStatus -> UserId
csTo :: !UserId,
    ConnectionStatus -> Relation
csStatus :: !Relation
  }
  deriving (ConnectionStatus -> ConnectionStatus -> Bool
(ConnectionStatus -> ConnectionStatus -> Bool)
-> (ConnectionStatus -> ConnectionStatus -> Bool)
-> Eq ConnectionStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConnectionStatus -> ConnectionStatus -> Bool
== :: ConnectionStatus -> ConnectionStatus -> Bool
$c/= :: ConnectionStatus -> ConnectionStatus -> Bool
/= :: ConnectionStatus -> ConnectionStatus -> Bool
Eq, Int -> ConnectionStatus -> ShowS
[ConnectionStatus] -> ShowS
ConnectionStatus -> String
(Int -> ConnectionStatus -> ShowS)
-> (ConnectionStatus -> String)
-> ([ConnectionStatus] -> ShowS)
-> Show ConnectionStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConnectionStatus -> ShowS
showsPrec :: Int -> ConnectionStatus -> ShowS
$cshow :: ConnectionStatus -> String
show :: ConnectionStatus -> String
$cshowList :: [ConnectionStatus] -> ShowS
showList :: [ConnectionStatus] -> ShowS
Show, (forall x. ConnectionStatus -> Rep ConnectionStatus x)
-> (forall x. Rep ConnectionStatus x -> ConnectionStatus)
-> Generic ConnectionStatus
forall x. Rep ConnectionStatus x -> ConnectionStatus
forall x. ConnectionStatus -> Rep ConnectionStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ConnectionStatus -> Rep ConnectionStatus x
from :: forall x. ConnectionStatus -> Rep ConnectionStatus x
$cto :: forall x. Rep ConnectionStatus x -> ConnectionStatus
to :: forall x. Rep ConnectionStatus x -> ConnectionStatus
Generic)
  deriving ([ConnectionStatus] -> Value
[ConnectionStatus] -> Encoding
ConnectionStatus -> Value
ConnectionStatus -> Encoding
(ConnectionStatus -> Value)
-> (ConnectionStatus -> Encoding)
-> ([ConnectionStatus] -> Value)
-> ([ConnectionStatus] -> Encoding)
-> ToJSON ConnectionStatus
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: ConnectionStatus -> Value
toJSON :: ConnectionStatus -> Value
$ctoEncoding :: ConnectionStatus -> Encoding
toEncoding :: ConnectionStatus -> Encoding
$ctoJSONList :: [ConnectionStatus] -> Value
toJSONList :: [ConnectionStatus] -> Value
$ctoEncodingList :: [ConnectionStatus] -> Encoding
toEncodingList :: [ConnectionStatus] -> Encoding
ToJSON, Value -> Parser [ConnectionStatus]
Value -> Parser ConnectionStatus
(Value -> Parser ConnectionStatus)
-> (Value -> Parser [ConnectionStatus])
-> FromJSON ConnectionStatus
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser ConnectionStatus
parseJSON :: Value -> Parser ConnectionStatus
$cparseJSONList :: Value -> Parser [ConnectionStatus]
parseJSONList :: Value -> Parser [ConnectionStatus]
FromJSON, Typeable ConnectionStatus
Typeable ConnectionStatus =>
(Proxy ConnectionStatus
 -> Declare (Definitions Schema) NamedSchema)
-> ToSchema ConnectionStatus
Proxy ConnectionStatus -> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a =>
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy ConnectionStatus -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy ConnectionStatus -> Declare (Definitions Schema) NamedSchema
S.ToSchema) via (Schema ConnectionStatus)

instance ToSchema ConnectionStatus where
  schema :: ValueSchema NamedSwaggerDoc ConnectionStatus
schema =
    Text
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionStatus ConnectionStatus
-> ValueSchema NamedSwaggerDoc ConnectionStatus
forall doc doc' a b.
HasObject doc doc' =>
Text
-> SchemaP doc Object [Pair] a b -> SchemaP doc' Value Value a b
object Text
"ConnectionStatus" (SchemaP SwaggerDoc Object [Pair] ConnectionStatus ConnectionStatus
 -> ValueSchema NamedSwaggerDoc ConnectionStatus)
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionStatus ConnectionStatus
-> ValueSchema NamedSwaggerDoc ConnectionStatus
forall a b. (a -> b) -> a -> b
$
      UserId -> UserId -> Relation -> ConnectionStatus
ConnectionStatus
        (UserId -> UserId -> Relation -> ConnectionStatus)
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatus UserId
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionStatus
     (UserId -> Relation -> ConnectionStatus)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConnectionStatus -> UserId
csFrom (ConnectionStatus -> UserId)
-> SchemaP SwaggerDoc Object [Pair] UserId UserId
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatus UserId
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> ValueSchema NamedSwaggerDoc UserId
-> SchemaP SwaggerDoc Object [Pair] UserId UserId
forall doc' doc a b.
HasField doc' doc =>
Text
-> SchemaP doc' Value Value a b -> SchemaP doc Object [Pair] a b
field Text
"from" ValueSchema NamedSwaggerDoc UserId
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  ConnectionStatus
  (UserId -> Relation -> ConnectionStatus)
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatus UserId
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionStatus
     (Relation -> ConnectionStatus)
forall a b.
SchemaP SwaggerDoc Object [Pair] ConnectionStatus (a -> b)
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatus a
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatus b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConnectionStatus -> UserId
csTo (ConnectionStatus -> UserId)
-> SchemaP SwaggerDoc Object [Pair] UserId UserId
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatus UserId
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> ValueSchema NamedSwaggerDoc UserId
-> SchemaP SwaggerDoc Object [Pair] UserId UserId
forall doc' doc a b.
HasField doc' doc =>
Text
-> SchemaP doc' Value Value a b -> SchemaP doc Object [Pair] a b
field Text
"to" ValueSchema NamedSwaggerDoc UserId
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  ConnectionStatus
  (Relation -> ConnectionStatus)
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatus Relation
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionStatus ConnectionStatus
forall a b.
SchemaP SwaggerDoc Object [Pair] ConnectionStatus (a -> b)
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatus a
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatus b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConnectionStatus -> Relation
csStatus (ConnectionStatus -> Relation)
-> SchemaP SwaggerDoc Object [Pair] Relation Relation
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatus Relation
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> SchemaP NamedSwaggerDoc Value Value Relation Relation
-> SchemaP SwaggerDoc Object [Pair] Relation Relation
forall doc' doc a b.
HasField doc' doc =>
Text
-> SchemaP doc' Value Value a b -> SchemaP doc Object [Pair] a b
field Text
"status" SchemaP NamedSwaggerDoc Value Value Relation Relation
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema

data ConnectionStatusV2 = ConnectionStatusV2
  { ConnectionStatusV2 -> UserId
csv2From :: !UserId,
    ConnectionStatusV2 -> Qualified UserId
csv2To :: !(Qualified UserId),
    ConnectionStatusV2 -> Relation
csv2Status :: !Relation
  }
  deriving (ConnectionStatusV2 -> ConnectionStatusV2 -> Bool
(ConnectionStatusV2 -> ConnectionStatusV2 -> Bool)
-> (ConnectionStatusV2 -> ConnectionStatusV2 -> Bool)
-> Eq ConnectionStatusV2
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConnectionStatusV2 -> ConnectionStatusV2 -> Bool
== :: ConnectionStatusV2 -> ConnectionStatusV2 -> Bool
$c/= :: ConnectionStatusV2 -> ConnectionStatusV2 -> Bool
/= :: ConnectionStatusV2 -> ConnectionStatusV2 -> Bool
Eq, Int -> ConnectionStatusV2 -> ShowS
[ConnectionStatusV2] -> ShowS
ConnectionStatusV2 -> String
(Int -> ConnectionStatusV2 -> ShowS)
-> (ConnectionStatusV2 -> String)
-> ([ConnectionStatusV2] -> ShowS)
-> Show ConnectionStatusV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConnectionStatusV2 -> ShowS
showsPrec :: Int -> ConnectionStatusV2 -> ShowS
$cshow :: ConnectionStatusV2 -> String
show :: ConnectionStatusV2 -> String
$cshowList :: [ConnectionStatusV2] -> ShowS
showList :: [ConnectionStatusV2] -> ShowS
Show, (forall x. ConnectionStatusV2 -> Rep ConnectionStatusV2 x)
-> (forall x. Rep ConnectionStatusV2 x -> ConnectionStatusV2)
-> Generic ConnectionStatusV2
forall x. Rep ConnectionStatusV2 x -> ConnectionStatusV2
forall x. ConnectionStatusV2 -> Rep ConnectionStatusV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ConnectionStatusV2 -> Rep ConnectionStatusV2 x
from :: forall x. ConnectionStatusV2 -> Rep ConnectionStatusV2 x
$cto :: forall x. Rep ConnectionStatusV2 x -> ConnectionStatusV2
to :: forall x. Rep ConnectionStatusV2 x -> ConnectionStatusV2
Generic)
  deriving ([ConnectionStatusV2] -> Value
[ConnectionStatusV2] -> Encoding
ConnectionStatusV2 -> Value
ConnectionStatusV2 -> Encoding
(ConnectionStatusV2 -> Value)
-> (ConnectionStatusV2 -> Encoding)
-> ([ConnectionStatusV2] -> Value)
-> ([ConnectionStatusV2] -> Encoding)
-> ToJSON ConnectionStatusV2
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: ConnectionStatusV2 -> Value
toJSON :: ConnectionStatusV2 -> Value
$ctoEncoding :: ConnectionStatusV2 -> Encoding
toEncoding :: ConnectionStatusV2 -> Encoding
$ctoJSONList :: [ConnectionStatusV2] -> Value
toJSONList :: [ConnectionStatusV2] -> Value
$ctoEncodingList :: [ConnectionStatusV2] -> Encoding
toEncodingList :: [ConnectionStatusV2] -> Encoding
ToJSON, Value -> Parser [ConnectionStatusV2]
Value -> Parser ConnectionStatusV2
(Value -> Parser ConnectionStatusV2)
-> (Value -> Parser [ConnectionStatusV2])
-> FromJSON ConnectionStatusV2
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser ConnectionStatusV2
parseJSON :: Value -> Parser ConnectionStatusV2
$cparseJSONList :: Value -> Parser [ConnectionStatusV2]
parseJSONList :: Value -> Parser [ConnectionStatusV2]
FromJSON, Typeable ConnectionStatusV2
Typeable ConnectionStatusV2 =>
(Proxy ConnectionStatusV2
 -> Declare (Definitions Schema) NamedSchema)
-> ToSchema ConnectionStatusV2
Proxy ConnectionStatusV2
-> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a =>
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy ConnectionStatusV2
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy ConnectionStatusV2
-> Declare (Definitions Schema) NamedSchema
S.ToSchema) via (Schema ConnectionStatusV2)

instance ToSchema ConnectionStatusV2 where
  schema :: ValueSchema NamedSwaggerDoc ConnectionStatusV2
schema =
    Text
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionStatusV2 ConnectionStatusV2
-> ValueSchema NamedSwaggerDoc ConnectionStatusV2
forall doc doc' a b.
HasObject doc doc' =>
Text
-> SchemaP doc Object [Pair] a b -> SchemaP doc' Value Value a b
object Text
"ConnectionStatusV2" (SchemaP
   SwaggerDoc Object [Pair] ConnectionStatusV2 ConnectionStatusV2
 -> ValueSchema NamedSwaggerDoc ConnectionStatusV2)
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionStatusV2 ConnectionStatusV2
-> ValueSchema NamedSwaggerDoc ConnectionStatusV2
forall a b. (a -> b) -> a -> b
$
      UserId -> Qualified UserId -> Relation -> ConnectionStatusV2
ConnectionStatusV2
        (UserId -> Qualified UserId -> Relation -> ConnectionStatusV2)
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatusV2 UserId
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionStatusV2
     (Qualified UserId -> Relation -> ConnectionStatusV2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConnectionStatusV2 -> UserId
csv2From (ConnectionStatusV2 -> UserId)
-> SchemaP SwaggerDoc Object [Pair] UserId UserId
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatusV2 UserId
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> ValueSchema NamedSwaggerDoc UserId
-> SchemaP SwaggerDoc Object [Pair] UserId UserId
forall doc' doc a b.
HasField doc' doc =>
Text
-> SchemaP doc' Value Value a b -> SchemaP doc Object [Pair] a b
field Text
"from" ValueSchema NamedSwaggerDoc UserId
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  ConnectionStatusV2
  (Qualified UserId -> Relation -> ConnectionStatusV2)
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionStatusV2 (Qualified UserId)
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     ConnectionStatusV2
     (Relation -> ConnectionStatusV2)
forall a b.
SchemaP SwaggerDoc Object [Pair] ConnectionStatusV2 (a -> b)
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatusV2 a
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatusV2 b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConnectionStatusV2 -> Qualified UserId
csv2To (ConnectionStatusV2 -> Qualified UserId)
-> SchemaP
     SwaggerDoc Object [Pair] (Qualified UserId) (Qualified UserId)
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionStatusV2 (Qualified UserId)
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> ValueSchema NamedSwaggerDoc (Qualified UserId)
-> SchemaP
     SwaggerDoc Object [Pair] (Qualified UserId) (Qualified UserId)
forall doc' doc a b.
HasField doc' doc =>
Text
-> SchemaP doc' Value Value a b -> SchemaP doc Object [Pair] a b
field Text
"qualified_to" ValueSchema NamedSwaggerDoc (Qualified UserId)
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  ConnectionStatusV2
  (Relation -> ConnectionStatusV2)
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatusV2 Relation
-> SchemaP
     SwaggerDoc Object [Pair] ConnectionStatusV2 ConnectionStatusV2
forall a b.
SchemaP SwaggerDoc Object [Pair] ConnectionStatusV2 (a -> b)
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatusV2 a
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatusV2 b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConnectionStatusV2 -> Relation
csv2Status (ConnectionStatusV2 -> Relation)
-> SchemaP SwaggerDoc Object [Pair] Relation Relation
-> SchemaP SwaggerDoc Object [Pair] ConnectionStatusV2 Relation
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> SchemaP NamedSwaggerDoc Value Value Relation Relation
-> SchemaP SwaggerDoc Object [Pair] Relation Relation
forall doc' doc a b.
HasField doc' doc =>
Text
-> SchemaP doc' Value Value a b -> SchemaP doc Object [Pair] a b
field Text
"status" SchemaP NamedSwaggerDoc Value Value Relation Relation
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema