module API.BrigInternal where

import API.BrigCommon
import API.Common
import qualified Data.Aeson as Aeson
import Data.Aeson.Types (Pair)
import Data.Function
import Data.Maybe
import Testlib.Prelude

data CreateUser = CreateUser
  { CreateUser -> Maybe String
email :: Maybe String,
    CreateUser -> Maybe String
password :: Maybe String,
    CreateUser -> Maybe String
name :: Maybe String,
    CreateUser -> Bool
team :: Bool,
    CreateUser -> Bool
activate :: Bool,
    CreateUser -> Maybe [String]
supportedProtocols :: Maybe [String]
  }

instance Default CreateUser where
  def :: CreateUser
def =
    CreateUser
      { $sel:email:CreateUser :: Maybe String
email = Maybe String
forall a. Maybe a
Nothing,
        $sel:password:CreateUser :: Maybe String
password = Maybe String
forall a. Maybe a
Nothing,
        $sel:name:CreateUser :: Maybe String
name = Maybe String
forall a. Maybe a
Nothing,
        $sel:team:CreateUser :: Bool
team = Bool
False,
        $sel:activate:CreateUser :: Bool
activate = Bool
True,
        $sel:supportedProtocols:CreateUser :: Maybe [String]
supportedProtocols = Maybe [String]
forall a. Maybe a
Nothing
      }

createUser :: (HasCallStack, MakesValue domain) => domain -> CreateUser -> App Response
createUser :: forall domain.
(HasCallStack, MakesValue domain) =>
domain -> CreateUser -> App Response
createUser domain
domain CreateUser
cu = do
  String
re <- App String
randomEmail
  let Maybe String
email :: Maybe String = Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard CreateUser
cu.activate Maybe () -> String -> Maybe String
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe String
re CreateUser
cu.email
  let password :: String
password = String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe String
defPassword CreateUser
cu.password
      name :: String
name = String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe String
"default" (CreateUser
cu.name Maybe String -> Maybe String -> Maybe String
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe String
email)
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned String
"/i/users"
  String -> Request -> App Response
submit String
"POST" (Request -> App Response) -> Request -> App Response
forall a b. (a -> b) -> a -> b
$
    Request
req
      Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [Pair] -> Request -> Request
addJSONObject
        ( [String
"email" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
e | String
e <- Maybe String -> [String]
forall a. Maybe a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Maybe String
email]
            [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [ String
"name" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
name,
                 String
"password" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
password,
                 String
"icon" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
"default"
               ]
            [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [String
"supported_protocols" String -> [String] -> Pair
forall a. ToJSON a => String -> a -> Pair
.= [String]
prots | [String]
prots <- Maybe [String] -> [[String]]
forall a. Maybe a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList CreateUser
cu.supportedProtocols]
            [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [ String
"team"
                   String -> Value -> Pair
forall a. ToJSON a => String -> a -> Pair
.= [Pair] -> Value
object
                     [ String
"name" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
"integration test team",
                       String
"icon" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
"default"
                     ]
                 | CreateUser
cu.team
               ]
        )

-- | https://staging-nginz-https.zinfra.io/api-internal/swagger-ui/brig/#/brig/get_i_users
getUsersId :: (HasCallStack, MakesValue domain) => domain -> [String] -> App Response
getUsersId :: forall domain.
(HasCallStack, MakesValue domain) =>
domain -> [String] -> App Response
getUsersId domain
domain [String]
ids = do
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned String
"/i/users"
  String -> Request -> App Response
submit String
"GET" (Request -> App Response) -> Request -> App Response
forall a b. (a -> b) -> a -> b
$ Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [(String, String)] -> Request -> Request
addQueryParams [(String
"ids", String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
"," [String]
ids)]

data FedConn = FedConn
  { FedConn -> String
domain :: String,
    FedConn -> String
searchStrategy :: String,
    FedConn -> Maybe [String]
restriction :: Maybe [String]
  }
  deriving (FedConn -> FedConn -> Bool
(FedConn -> FedConn -> Bool)
-> (FedConn -> FedConn -> Bool) -> Eq FedConn
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FedConn -> FedConn -> Bool
== :: FedConn -> FedConn -> Bool
$c/= :: FedConn -> FedConn -> Bool
/= :: FedConn -> FedConn -> Bool
Eq, Eq FedConn
Eq FedConn =>
(FedConn -> FedConn -> Ordering)
-> (FedConn -> FedConn -> Bool)
-> (FedConn -> FedConn -> Bool)
-> (FedConn -> FedConn -> Bool)
-> (FedConn -> FedConn -> Bool)
-> (FedConn -> FedConn -> FedConn)
-> (FedConn -> FedConn -> FedConn)
-> Ord FedConn
FedConn -> FedConn -> Bool
FedConn -> FedConn -> Ordering
FedConn -> FedConn -> FedConn
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FedConn -> FedConn -> Ordering
compare :: FedConn -> FedConn -> Ordering
$c< :: FedConn -> FedConn -> Bool
< :: FedConn -> FedConn -> Bool
$c<= :: FedConn -> FedConn -> Bool
<= :: FedConn -> FedConn -> Bool
$c> :: FedConn -> FedConn -> Bool
> :: FedConn -> FedConn -> Bool
$c>= :: FedConn -> FedConn -> Bool
>= :: FedConn -> FedConn -> Bool
$cmax :: FedConn -> FedConn -> FedConn
max :: FedConn -> FedConn -> FedConn
$cmin :: FedConn -> FedConn -> FedConn
min :: FedConn -> FedConn -> FedConn
Ord, Int -> FedConn -> ShowS
[FedConn] -> ShowS
FedConn -> String
(Int -> FedConn -> ShowS)
-> (FedConn -> String) -> ([FedConn] -> ShowS) -> Show FedConn
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FedConn -> ShowS
showsPrec :: Int -> FedConn -> ShowS
$cshow :: FedConn -> String
show :: FedConn -> String
$cshowList :: [FedConn] -> ShowS
showList :: [FedConn] -> ShowS
Show)

instance ToJSON FedConn where
  toJSON :: FedConn -> Value
toJSON (FedConn String
d String
s Maybe [String]
r) =
    [Pair] -> Value
Aeson.object
      [ String
"domain" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
d,
        String
"search_policy" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
s,
        String
"restriction"
          String -> Value -> Pair
forall a. ToJSON a => String -> a -> Pair
.= Value -> ([String] -> Value) -> Maybe [String] -> Value
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
            ([Pair] -> Value
Aeson.object [String
"tag" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
"allow_all", String
"value" String -> Value -> Pair
forall a. ToJSON a => String -> a -> Pair
.= Value
Aeson.Null])
            ( \[String]
teams ->
                [Pair] -> Value
Aeson.object [String
"tag" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
"restrict_by_team", String
"value" String -> Value -> Pair
forall a. ToJSON a => String -> a -> Pair
.= [String] -> Value
forall a. ToJSON a => a -> Value
Aeson.toJSON [String]
teams]
            )
            Maybe [String]
r
      ]

instance MakesValue FedConn where
  make :: HasCallStack => FedConn -> App Value
make = Value -> App Value
forall a. a -> App a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Value -> App Value) -> (FedConn -> Value) -> FedConn -> App Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FedConn -> Value
forall a. ToJSON a => a -> Value
toJSON

createFedConn :: (HasCallStack, MakesValue dom, MakesValue fedConn) => dom -> fedConn -> App Response
createFedConn :: forall dom fedConn.
(HasCallStack, MakesValue dom, MakesValue fedConn) =>
dom -> fedConn -> App Response
createFedConn dom
dom fedConn
fedConn = do
  App Response -> (Response -> App Response) -> App Response
forall a.
HasCallStack =>
App Response -> (Response -> App a) -> App a
bindResponse (dom -> fedConn -> App Response
forall dom fedConn.
(HasCallStack, MakesValue dom, MakesValue fedConn) =>
dom -> fedConn -> App Response
createFedConn' dom
dom fedConn
fedConn) ((Response -> App Response) -> App Response)
-> (Response -> App Response) -> App Response
forall a b. (a -> b) -> a -> b
$ \Response
res -> do
    Response
res.status Int -> (Int, Int) -> App ()
forall a. (MakesValue a, HasCallStack) => a -> (Int, Int) -> App ()
`shouldMatchRange` (Int
200, Int
299)
    Response -> App Response
forall a. a -> App a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Response
res

createFedConn' :: (HasCallStack, MakesValue dom, MakesValue fedConn) => dom -> fedConn -> App Response
createFedConn' :: forall dom fedConn.
(HasCallStack, MakesValue dom, MakesValue fedConn) =>
dom -> fedConn -> App Response
createFedConn' dom
dom fedConn
fedConn = do
  Request
req <- dom -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
rawBaseRequest dom
dom Service
Brig Versioned
Unversioned String
"/i/federation/remotes"
  Value
conn <- fedConn -> App Value
forall a. (MakesValue a, HasCallStack) => a -> App Value
make fedConn
fedConn
  String -> Request -> App Response
submit String
"POST" (Request -> App Response) -> Request -> App Response
forall a b. (a -> b) -> a -> b
$ Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& Value -> Request -> Request
forall a. ToJSON a => a -> Request -> Request
addJSON Value
conn

readFedConns :: (HasCallStack, MakesValue dom) => dom -> App Response
readFedConns :: forall dom. (HasCallStack, MakesValue dom) => dom -> App Response
readFedConns dom
dom = do
  App Response -> (Response -> App Response) -> App Response
forall a.
HasCallStack =>
App Response -> (Response -> App a) -> App a
bindResponse (dom -> App Response
forall dom. (HasCallStack, MakesValue dom) => dom -> App Response
readFedConns' dom
dom) ((Response -> App Response) -> App Response)
-> (Response -> App Response) -> App Response
forall a b. (a -> b) -> a -> b
$ \Response
res -> do
    Response
res.status Int -> (Int, Int) -> App ()
forall a. (MakesValue a, HasCallStack) => a -> (Int, Int) -> App ()
`shouldMatchRange` (Int
200, Int
299)
    Response -> App Response
forall a. a -> App a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Response
res

readFedConns' :: (HasCallStack, MakesValue dom) => dom -> App Response
readFedConns' :: forall dom. (HasCallStack, MakesValue dom) => dom -> App Response
readFedConns' dom
dom = do
  Request
req <- dom -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
rawBaseRequest dom
dom Service
Brig Versioned
Unversioned String
"/i/federation/remotes"
  String -> Request -> App Response
submit String
"GET" Request
req

updateFedConn :: (HasCallStack, MakesValue owndom, MakesValue fedConn) => owndom -> String -> fedConn -> App Response
updateFedConn :: forall owndom fedConn.
(HasCallStack, MakesValue owndom, MakesValue fedConn) =>
owndom -> String -> fedConn -> App Response
updateFedConn owndom
owndom String
dom fedConn
fedConn = do
  App Response -> (Response -> App Response) -> App Response
forall a.
HasCallStack =>
App Response -> (Response -> App a) -> App a
bindResponse (owndom -> String -> fedConn -> App Response
forall owndom fedConn.
(HasCallStack, MakesValue owndom, MakesValue fedConn) =>
owndom -> String -> fedConn -> App Response
updateFedConn' owndom
owndom String
dom fedConn
fedConn) ((Response -> App Response) -> App Response)
-> (Response -> App Response) -> App Response
forall a b. (a -> b) -> a -> b
$ \Response
res -> do
    Response
res.status Int -> (Int, Int) -> App ()
forall a. (MakesValue a, HasCallStack) => a -> (Int, Int) -> App ()
`shouldMatchRange` (Int
200, Int
299)
    Response -> App Response
forall a. a -> App a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Response
res

updateFedConn' :: (HasCallStack, MakesValue owndom, MakesValue fedConn) => owndom -> String -> fedConn -> App Response
updateFedConn' :: forall owndom fedConn.
(HasCallStack, MakesValue owndom, MakesValue fedConn) =>
owndom -> String -> fedConn -> App Response
updateFedConn' owndom
owndom String
dom fedConn
fedConn = do
  Request
req <- owndom -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
rawBaseRequest owndom
owndom Service
Brig Versioned
Unversioned (String
"/i/federation/remotes/" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
dom)
  Value
conn <- fedConn -> App Value
forall a. (MakesValue a, HasCallStack) => a -> App Value
make fedConn
fedConn
  String -> Request -> App Response
submit String
"PUT" (Request -> App Response) -> Request -> App Response
forall a b. (a -> b) -> a -> b
$ Value -> Request -> Request
forall a. ToJSON a => a -> Request -> Request
addJSON Value
conn Request
req

registerOAuthClient :: (HasCallStack, MakesValue user, MakesValue name, MakesValue url) => user -> name -> url -> App Response
registerOAuthClient :: forall user name url.
(HasCallStack, MakesValue user, MakesValue name, MakesValue url) =>
user -> name -> url -> App Response
registerOAuthClient user
user name
name url
url = do
  Request
req <- user -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest user
user Service
Brig Versioned
Unversioned String
"i/oauth/clients"
  String
applicationName <- name -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
asString name
name
  String
redirectUrl <- url -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
asString url
url
  String -> Request -> App Response
submit String
"POST" (Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [Pair] -> Request -> Request
addJSONObject [String
"application_name" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
applicationName, String
"redirect_url" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
redirectUrl])

getOAuthClient :: (HasCallStack, MakesValue user, MakesValue cid) => user -> cid -> App Response
getOAuthClient :: forall dom fedConn.
(HasCallStack, MakesValue dom, MakesValue fedConn) =>
dom -> fedConn -> App Response
getOAuthClient user
user cid
cid = do
  String
clientId <- cid -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
objId cid
cid
  Request
req <- user -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest user
user Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ String
"i/oauth/clients/" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
clientId
  String -> Request -> App Response
submit String
"GET" Request
req

updateOAuthClient :: (HasCallStack, MakesValue user, MakesValue cid, MakesValue name, MakesValue url) => user -> cid -> name -> url -> App Response
updateOAuthClient :: forall user cid name url.
(HasCallStack, MakesValue user, MakesValue cid, MakesValue name,
 MakesValue url) =>
user -> cid -> name -> url -> App Response
updateOAuthClient user
user cid
cid name
name url
url = do
  String
clientId <- cid -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
objId cid
cid
  Request
req <- user -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest user
user Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ String
"i/oauth/clients/" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
clientId
  String
applicationName <- name -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
asString name
name
  String
redirectUrl <- url -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
asString url
url
  String -> Request -> App Response
submit String
"PUT" (Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [Pair] -> Request -> Request
addJSONObject [String
"application_name" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
applicationName, String
"redirect_url" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
redirectUrl])

deleteOAuthClient :: (HasCallStack, MakesValue user, MakesValue cid) => user -> cid -> App Response
deleteOAuthClient :: forall dom fedConn.
(HasCallStack, MakesValue dom, MakesValue fedConn) =>
dom -> fedConn -> App Response
deleteOAuthClient user
user cid
cid = do
  String
clientId <- cid -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
objId cid
cid
  Request
req <- user -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest user
user Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ String
"i/oauth/clients/" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
clientId
  String -> Request -> App Response
submit String
"DELETE" Request
req

getInvitationCode :: (HasCallStack, MakesValue user, MakesValue inv) => user -> inv -> App Response
getInvitationCode :: forall dom fedConn.
(HasCallStack, MakesValue dom, MakesValue fedConn) =>
dom -> fedConn -> App Response
getInvitationCode user
user inv
inv = do
  String
tid <- user
user user -> String -> App Value
forall a. (HasCallStack, MakesValue a) => a -> String -> App Value
%. String
"team" App Value -> (App Value -> App String) -> App String
forall a b. a -> (a -> b) -> b
& App Value -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
asString
  user -> String -> inv -> App Response
forall owndom fedConn.
(HasCallStack, MakesValue owndom, MakesValue fedConn) =>
owndom -> String -> fedConn -> App Response
getInvitationCodeForTeam user
user String
tid inv
inv

getInvitationCodeForTeam :: (HasCallStack, MakesValue domain, MakesValue inv) => domain -> String -> inv -> App Response
getInvitationCodeForTeam :: forall owndom fedConn.
(HasCallStack, MakesValue owndom, MakesValue fedConn) =>
owndom -> String -> fedConn -> App Response
getInvitationCodeForTeam domain
domain String
tid inv
inv = do
  String
invId <- inv
inv inv -> String -> App Value
forall a. (HasCallStack, MakesValue a) => a -> String -> App Value
%. String
"id" App Value -> (App Value -> App String) -> App String
forall a b. a -> (a -> b) -> b
& App Value -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
asString
  Request
req <-
    domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$
      String
"i/teams/invitation-code?team=" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
tid String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"&invitation_id=" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
invId
  String -> Request -> App Response
submit String
"GET" Request
req

refreshIndex :: (HasCallStack, MakesValue domain) => domain -> App ()
refreshIndex :: forall domain.
(HasCallStack, MakesValue domain) =>
domain -> App ()
refreshIndex domain
domain = do
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned String
"i/index/refresh"
  Response
res <- String -> Request -> App Response
submit String
"POST" Request
req
  Response
res.status Int -> Int -> App ()
forall a. (MakesValue a, HasCallStack) => a -> Int -> App ()
`shouldMatchInt` Int
200

addFederationRemoteTeam :: (HasCallStack, MakesValue domain, MakesValue remoteDomain, MakesValue team) => domain -> remoteDomain -> team -> App ()
addFederationRemoteTeam :: forall domain remoteDomain team.
(HasCallStack, MakesValue domain, MakesValue remoteDomain,
 MakesValue team) =>
domain -> remoteDomain -> team -> App ()
addFederationRemoteTeam domain
domain remoteDomain
remoteDomain team
team = do
  App ByteString -> App ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (App ByteString -> App ()) -> App ByteString -> App ()
forall a b. (a -> b) -> a -> b
$ domain -> remoteDomain -> team -> App Response
forall user name url.
(HasCallStack, MakesValue user, MakesValue name, MakesValue url) =>
user -> name -> url -> App Response
addFederationRemoteTeam' domain
domain remoteDomain
remoteDomain team
team App Response -> (Response -> App ByteString) -> App ByteString
forall a b. App a -> (a -> App b) -> App b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= HasCallStack => Int -> Response -> App ByteString
Int -> Response -> App ByteString
getBody Int
200

addFederationRemoteTeam' :: (HasCallStack, MakesValue domain, MakesValue remoteDomain, MakesValue team) => domain -> remoteDomain -> team -> App Response
addFederationRemoteTeam' :: forall user name url.
(HasCallStack, MakesValue user, MakesValue name, MakesValue url) =>
user -> name -> url -> App Response
addFederationRemoteTeam' domain
domain remoteDomain
remoteDomain team
team = do
  String
d <- remoteDomain -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
asString remoteDomain
remoteDomain
  Value
t <- team -> App Value
forall a. (MakesValue a, HasCallStack) => a -> App Value
make team
team
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"federation", String
"remotes", String
d, String
"teams"]
  String -> Request -> App Response
submit String
"POST" (Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [Pair] -> Request -> Request
addJSONObject [String
"team_id" String -> Value -> Pair
forall a. ToJSON a => String -> a -> Pair
.= Value
t])

getFederationRemoteTeams :: (HasCallStack, MakesValue domain, MakesValue remoteDomain) => domain -> remoteDomain -> App Response
getFederationRemoteTeams :: forall dom fedConn.
(HasCallStack, MakesValue dom, MakesValue fedConn) =>
dom -> fedConn -> App Response
getFederationRemoteTeams domain
domain remoteDomain
remoteDomain = do
  String
d <- remoteDomain -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
asString remoteDomain
remoteDomain
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"federation", String
"remotes", String
d, String
"teams"]
  String -> Request -> App Response
submit String
"GET" Request
req

deleteFederationRemoteTeam :: (HasCallStack, MakesValue domain, MakesValue remoteDomain, MakesValue team) => domain -> remoteDomain -> team -> App ()
deleteFederationRemoteTeam :: forall domain remoteDomain team.
(HasCallStack, MakesValue domain, MakesValue remoteDomain,
 MakesValue team) =>
domain -> remoteDomain -> team -> App ()
deleteFederationRemoteTeam domain
domain remoteDomain
remoteDomain team
team = do
  String
d <- remoteDomain -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
asString remoteDomain
remoteDomain
  String
t <- team -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
asString team
team
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"federation", String
"remotes", String
d, String
"teams", String
t]
  Response
res <- String -> Request -> App Response
submit String
"DELETE" Request
req
  Response
res.status Int -> Int -> App ()
forall a. (MakesValue a, HasCallStack) => a -> Int -> App ()
`shouldMatchInt` Int
200

getConnStatusForUsers :: (HasCallStack, MakesValue users) => users -> Domain -> App Response
getConnStatusForUsers :: forall users.
(HasCallStack, MakesValue users) =>
users -> Domain -> App Response
getConnStatusForUsers users
users Domain
domain = do
  [Value]
usersList <-
    users -> App [Value]
forall a. (HasCallStack, MakesValue a) => a -> App [Value]
asList users
users App [Value] -> ([Value] -> App [Value]) -> App [Value]
forall a b. App a -> (a -> App b) -> App b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Value]
us -> do
      [Value]
dom <- [Value]
us [Value] -> (Value -> App Value) -> App [Value]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
`for` (Value -> String -> App Value
forall a. (HasCallStack, MakesValue a) => a -> String -> App Value
%. String
"qualified_id.domain")
      [Value]
dom [Value] -> (Value -> App ()) -> App ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
t a -> (a -> f b) -> f ()
`for_` (Value -> App Value -> App ()
forall a b.
(MakesValue a, MakesValue b, HasCallStack) =>
a -> b -> App ()
`shouldMatch` Domain -> App Value
forall a. (MakesValue a, HasCallStack) => a -> App Value
make Domain
domain)
      [Value]
us [Value] -> (Value -> App Value) -> App [Value]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
`for` (Value -> String -> App Value
forall a. (HasCallStack, MakesValue a) => a -> String -> App Value
%. String
"id")
  Value
usersJSON <- [Value] -> App Value
forall a. (MakesValue a, HasCallStack) => a -> App Value
make [Value]
usersList
  HasCallStack => [Pair] -> Domain -> App Response
[Pair] -> Domain -> App Response
getConnStatusInternal [String
"from" String -> Value -> Pair
forall a. ToJSON a => String -> a -> Pair
.= Value
usersJSON] Domain
domain

getConnStatusInternal :: (HasCallStack) => [Pair] -> Domain -> App Response
getConnStatusInternal :: HasCallStack => [Pair] -> Domain -> App Response
getConnStatusInternal [Pair]
body Domain
dom = do
  Request
req <- Domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest Domain
dom Service
Brig Versioned
Unversioned do
    [String] -> String
joinHttpPath [String
"i", String
"users", String
"connections-status", String
"v2"]
  String -> Request -> App Response
submit String
"POST" do
    Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [Pair] -> Request -> Request
addJSONObject [Pair]
body

getProviderActivationCodeInternal ::
  (HasCallStack, MakesValue dom) =>
  dom ->
  String ->
  App Response
getProviderActivationCodeInternal :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> App Response
getProviderActivationCodeInternal dom
dom String
email = do
  Value
d <- dom -> App Value
forall a. (MakesValue a, HasCallStack) => a -> App Value
make dom
dom
  Request
req <-
    Value -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
rawBaseRequest Value
d Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$
      [String] -> String
joinHttpPath [String
"i", String
"provider", String
"activation-code"]
  String -> Request -> App Response
submit String
"GET" ([(String, String)] -> Request -> Request
addQueryParams [(String
"email", String
email)] Request
req)

-- | https://staging-nginz-https.zinfra.io/api-internal/swagger-ui/brig/#/brig/post_i_clients__uid_
addClient ::
  (HasCallStack, MakesValue user) =>
  user ->
  AddClient ->
  App Response
addClient :: forall user.
(HasCallStack, MakesValue user) =>
user -> AddClient -> App Response
addClient user
user AddClient
args = do
  String
uid <- user -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
objId user
user
  Request
req <- user -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest user
user Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ String
"/i/clients/" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
uid
  [Pair]
val <- AddClient -> App [Pair]
mkAddClientValue AddClient
args
  String -> Request -> App Response
submit String
"POST" (Request -> App Response) -> Request -> App Response
forall a b. (a -> b) -> a -> b
$ Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [Pair] -> Request -> Request
addJSONObject [Pair]
val

-- | https://staging-nginz-https.zinfra.io/api-internal/swagger-ui/brig/#/brig/post_i_clients_full
getClientsFull :: (HasCallStack, MakesValue users, MakesValue uid) => uid -> users -> App Response
getClientsFull :: forall users uid.
(HasCallStack, MakesValue users, MakesValue uid) =>
uid -> users -> App Response
getClientsFull uid
user users
users = do
  Value
val <- users -> App Value
forall a. (MakesValue a, HasCallStack) => a -> App Value
make users
users
  uid -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest uid
user Service
Brig Versioned
Unversioned do [String] -> String
joinHttpPath [String
"i", String
"clients", String
"full"]
    App Request -> (Request -> App Response) -> App Response
forall a b. App a -> (a -> App b) -> App b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= String -> Request -> App Response
submit String
"POST"
    (Request -> App Response)
-> (Request -> Request) -> Request -> App Response
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pair] -> Request -> Request
addJSONObject [String
"users" String -> Value -> Pair
forall a. ToJSON a => String -> a -> Pair
.= Value
val]

-- | https://staging-nginz-https.zinfra.io/api-internal/swagger-ui/brig/#/brig/post_i_ejpd_request
getEJPDInfo :: (HasCallStack, MakesValue dom) => dom -> [String] -> String -> App Response
getEJPDInfo :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> [String] -> String -> App Response
getEJPDInfo dom
dom [String]
handles String
mode = do
  Request
req <- dom -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
rawBaseRequest dom
dom Service
Brig Versioned
Unversioned String
"/i/ejpd-request"
  let query :: [(String, String)]
query = case String
mode of
        String
"" -> []
        String
"include_contacts" -> [(String
"include_contacts", String
"true")]
        String
bad -> String -> [(String, String)]
forall a. HasCallStack => String -> a
error (String -> [(String, String)]) -> String -> [(String, String)]
forall a b. (a -> b) -> a -> b
$ ShowS
forall a. Show a => a -> String
show String
bad
  String -> Request -> App Response
submit String
"POST" (Request -> App Response) -> Request -> App Response
forall a b. (a -> b) -> a -> b
$ Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [Pair] -> Request -> Request
addJSONObject [String
"EJPDRequest" String -> [String] -> Pair
forall a. ToJSON a => String -> a -> Pair
.= [String]
handles] Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [(String, String)] -> Request -> Request
addQueryParams [(String, String)]
query

-- | https://staging-nginz-https.zinfra.io/api-internal/swagger-ui/brig/#/brig/get_i_users__uid__verification_code__action_
getVerificationCode :: (HasCallStack, MakesValue user) => user -> String -> App Response
getVerificationCode :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> App Response
getVerificationCode user
user String
action = do
  String
uid <- user -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
objId user
user
  String
domain <- user -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
objDomain user
user
  Request
req <- String -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest String
domain Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"users", String
uid, String
"verification-code", String
action]
  String -> Request -> App Response
submit String
"GET" Request
req

-- | http://staging-nginz-https.zinfra.io/api-internal/swagger-ui/brig/#/brig/get_i_users__uid__features_conferenceCalling
getFeatureForUser :: (HasCallStack, MakesValue user) => user -> String -> App Response
getFeatureForUser :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> App Response
getFeatureForUser user
user String
featureName = do
  String
uid <- user -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
objId user
user
  Request
req <- user -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest user
user Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"users", String
uid, String
"features", String
featureName]
  String -> Request -> App Response
submit String
"GET" Request
req

-- | http://staging-nginz-https.zinfra.io/api-internal/swagger-ui/brig/#/brig/put_i_users__uid__features_conferenceCalling
putFeatureForUser ::
  (HasCallStack, MakesValue user, MakesValue config) =>
  user ->
  String ->
  config ->
  App Response
putFeatureForUser :: forall owndom fedConn.
(HasCallStack, MakesValue owndom, MakesValue fedConn) =>
owndom -> String -> fedConn -> App Response
putFeatureForUser user
user String
featureName config
config = do
  String
uid <- user -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
objId user
user
  Request
req <- user -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest user
user Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"users", String
uid, String
"features", String
featureName]
  Value
configValue <- config -> App Value
forall a. (MakesValue a, HasCallStack) => a -> App Value
make config
config
  String -> Request -> App Response
submit String
"PUT" (Request -> App Response) -> Request -> App Response
forall a b. (a -> b) -> a -> b
$ Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& Value -> Request -> Request
forall a. ToJSON a => a -> Request -> Request
addJSON Value
configValue

-- | http://staging-nginz-https.zinfra.io/api-internal/swagger-ui/brig/#/brig/delete_i_users__uid__features_conferenceCalling
deleteFeatureForUser :: (HasCallStack, MakesValue user) => user -> String -> App Response
deleteFeatureForUser :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> App Response
deleteFeatureForUser user
user String
featureName = do
  String
uid <- user -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
objId user
user
  Request
req <- user -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest user
user Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"users", String
uid, String
"features", String
featureName]
  String -> Request -> App Response
submit String
"DELETE" Request
req

-- | https://staging-nginz-https.zinfra.io/api-internal/swagger-ui/brig/#/brig/post_i_oauth_clients
createOAuthClient :: (HasCallStack, MakesValue user) => user -> String -> String -> App Response
createOAuthClient :: forall user.
(HasCallStack, MakesValue user) =>
user -> String -> String -> App Response
createOAuthClient user
user String
name String
url = do
  Request
req <- user -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest user
user Service
Brig Versioned
Unversioned String
"i/oauth/clients"
  String -> Request -> App Response
submit String
"POST" (Request -> App Response) -> Request -> App Response
forall a b. (a -> b) -> a -> b
$ Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [Pair] -> Request -> Request
addJSONObject [String
"application_name" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
name, String
"redirect_url" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
url]

getInvitationByEmail :: (HasCallStack, MakesValue domain) => domain -> String -> App Response
getInvitationByEmail :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> App Response
getInvitationByEmail domain
domain String
email = do
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned String
"i/teams/invitations/by-email"
  String -> Request -> App Response
submit String
"GET" (Request -> App Response) -> Request -> App Response
forall a b. (a -> b) -> a -> b
$ Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [(String, String)] -> Request -> Request
addQueryParams [(String
"email", String
email)]

getActivationCode :: (HasCallStack, MakesValue domain) => domain -> String -> App Response
getActivationCode :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> App Response
getActivationCode domain
domain String
email = do
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned String
"i/users/activation-code"
  String -> Request -> App Response
submit String
"GET" (Request -> App Response) -> Request -> App Response
forall a b. (a -> b) -> a -> b
$ Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [(String, String)] -> Request -> Request
addQueryParams [(String
"email", String
email)]

getPasswordResetCode :: (HasCallStack, MakesValue domain) => domain -> String -> App Response
getPasswordResetCode :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> App Response
getPasswordResetCode domain
domain String
email = do
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned String
"i/users/password-reset-code"
  String -> Request -> App Response
submit String
"GET" (Request -> App Response) -> Request -> App Response
forall a b. (a -> b) -> a -> b
$ Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [(String, String)] -> Request -> Request
addQueryParams [(String
"email", String
email)]

data PutSSOId = PutSSOId
  { PutSSOId -> Maybe String
scimExternalId :: Maybe String,
    PutSSOId -> Maybe String
subject :: Maybe String,
    PutSSOId -> Maybe String
tenant :: Maybe String
  }

instance Default PutSSOId where
  def :: PutSSOId
def =
    PutSSOId
      { $sel:scimExternalId:PutSSOId :: Maybe String
scimExternalId = Maybe String
forall a. Maybe a
Nothing,
        $sel:subject:PutSSOId :: Maybe String
subject = Maybe String
forall a. Maybe a
Nothing,
        $sel:tenant:PutSSOId :: Maybe String
tenant = Maybe String
forall a. Maybe a
Nothing
      }

putSSOId :: (HasCallStack, MakesValue user) => user -> PutSSOId -> App Response
putSSOId :: forall user.
(HasCallStack, MakesValue user) =>
user -> PutSSOId -> App Response
putSSOId user
user PutSSOId
args = do
  String
uid <- user -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
objId user
user
  Request
req <- user -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest user
user Service
Brig Versioned
Unversioned ([String] -> String
joinHttpPath [String
"i", String
"users", String
uid, String
"sso-id"])
  String -> Request -> App Response
submit String
"PUT" (Request -> App Response) -> Request -> App Response
forall a b. (a -> b) -> a -> b
$
    Request
req
      Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& [Pair] -> Request -> Request
addJSONObject
        [ String
"scim_external_id" String -> Maybe String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= PutSSOId
args.scimExternalId,
          String
"subject" String -> Maybe String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= PutSSOId
args.subject,
          String
"tenant" String -> Maybe String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= PutSSOId
args.tenant
        ]

domainRegistrationLock :: (HasCallStack, MakesValue domain) => domain -> String -> App Response
domainRegistrationLock :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> App Response
domainRegistrationLock domain
domain String
registrationDomain = do
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"domain-registration", String
registrationDomain, String
"lock"]
  String -> Request -> App Response
submit String
"POST" Request
req

domainRegistrationUnlock :: (HasCallStack, MakesValue domain) => domain -> String -> App Response
domainRegistrationUnlock :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> App Response
domainRegistrationUnlock domain
domain String
registrationDomain = do
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"domain-registration", String
registrationDomain, String
"unlock"]
  String -> Request -> App Response
submit String
"POST" Request
req

domainRegistrationPreAuthorize :: (HasCallStack, MakesValue domain) => domain -> String -> App Response
domainRegistrationPreAuthorize :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> App Response
domainRegistrationPreAuthorize domain
domain String
registrationDomain = do
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"domain-registration", String
registrationDomain, String
"preauthorize"]
  String -> Request -> App Response
submit String
"POST" Request
req

domainRegistrationUnAuthorize :: (HasCallStack, MakesValue domain) => domain -> String -> App Response
domainRegistrationUnAuthorize :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> App Response
domainRegistrationUnAuthorize domain
domain String
registrationDomain = do
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"domain-registration", String
registrationDomain, String
"unauthorize"]
  String -> Request -> App Response
submit String
"POST" Request
req

updateDomainRegistration :: (HasCallStack, MakesValue domain) => domain -> String -> Value -> App Response
updateDomainRegistration :: forall domain.
(HasCallStack, MakesValue domain) =>
domain -> String -> Value -> App Response
updateDomainRegistration domain
domain String
registrationDomain Value
payload = do
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"domain-registration", String
registrationDomain]
  String -> Request -> App Response
submit String
"PUT" (Request -> App Response) -> Request -> App Response
forall a b. (a -> b) -> a -> b
$ Request
req Request -> (Request -> Request) -> Request
forall a b. a -> (a -> b) -> b
& Value -> Request -> Request
forall a. ToJSON a => a -> Request -> Request
addJSON Value
payload

deleteDomainRegistration :: (HasCallStack, MakesValue domain) => domain -> String -> App Response
deleteDomainRegistration :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> App Response
deleteDomainRegistration domain
domain String
registrationDomain = do
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"domain-registration", String
registrationDomain]
  String -> Request -> App Response
submit String
"DELETE" Request
req

getDomainRegistration :: (HasCallStack, MakesValue domain) => domain -> String -> App Response
getDomainRegistration :: forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> App Response
getDomainRegistration domain
domain String
registrationDomain = do
  Request
req <- domain -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest domain
domain Service
Brig Versioned
Unversioned (String -> App Request) -> String -> App Request
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinHttpPath [String
"i", String
"domain-registration", String
registrationDomain]
  String -> Request -> App Response
submit String
"GET" Request
req