-- |
-- Module: PowerDNS.Client
-- Description: Servant client functions and utilities to interact with a PowerDNS Server
--
-- All the endpoints provide only a very slim wrapper around the PowerDNS API preserving
-- its idiosyncracies.

{-# LANGUAGE OverloadedStrings #-}
module PowerDNS.Client
  (
  -- * Authentication
    applyXApiKey

  -- * Version
  , listVersions
  , Version(..)

  -- * Zones
  --
  -- | See documentation at [PowerDNS Zones API](https://doc.powerdns.com/authoritative/http-api/zone.html)
  --
  -- Because the required fields of a 'Zone' differs between various requests and responses, every field
  -- is wrapped with Maybe. It is the users responsibility to check with the PowerDNS API to know when a
  -- field must be specified. For convenience 'empty' can be used to generate a value of 'Zone' with all
  -- fields set to 'Nothing'.
  --
  -- @
  --    let zone = empty { zone_name = Just "some.domain."
  --                     , zone_kind = Just Native
  --                     , zone_type = Just "zone" }
  --
  --    in createZone "localhost" -- Server ID
  --                  Nothing     -- Show RRsets in response
  --                  zone        -- The zone we are creating
  -- @
  , listZones
  , createZone
  , getZone
  , deleteZone
  , updateRecords
  , updateZone
  , triggerAxfr
  , notifySlaves
  , getZoneAxfr
  , rectifyZone
  -- ** Data types
  , Zone(..)
  , Kind(..)
  , RRSets(..)
  , RRSet(..)
  , Record(..)
  , Comment(..)
  , ChangeType(..)
  , RecordType(..)
  , Result(..)

  -- * Cryptokeys
  -- | See documentation at [PowerDNS Cryptokeys API](https://doc.powerdns.com/authoritative/http-api/cryptokey.html)
  , listCryptoKeys
  , createCryptokey
  , getCryptokey
  , updateCryptokey
  , deleteCryptokey
  -- ** Data types
  , Cryptokey

  -- * Servers
  -- | See documentation at [PowerDNS Servers API](https://doc.powerdns.com/authoritative/http-api/server.html)
  --
  -- Also contains [PowerDNS Search API](https://doc.powerdns.com/authoritative/http-api/search.html)
  -- and [PowerDNS Cache API](https://doc.powerdns.com/authoritative/http-api/cache.html)
  , listServers
  , getServer
  , search
  , flushCache
  , statistics
  -- ** Data types
  , Server(..)
  , SearchResult(..)
  , ObjectType(..)
  , CacheFlushResult(..)

  -- * Metadata
  -- | See documentation at [PowerDNS Metadata API](https://doc.powerdns.com/authoritative/http-api/metadata.html)
  , listMetadata
  , createMetadata
  , getMetadata
  , updateMetadata
  , deleteMetadata
  -- ** Data types
  , Metadata(..)

  -- * TSIGKeys
  -- | See documentation at [PowerDNS TSIGKeys API](https://doc.powerdns.com/authoritative/http-api/metadata.html)
  -- as well as related [TSIG documentation](https://doc.powerdns.com/authoritative/tsig.html)
  , listTSIGKeys
  , createTSIGKey
  , getTSIGKey
  , updateTSIGKey
  , deleteTSIGKey

  -- ** Data types
  , TSIGKey(..)
  , TSIGAlgorithm(..)

  -- * Utilities
  , empty
  )
where

import qualified Data.CaseInsensitive as CI
import           Data.Sequence ((|>))
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import           Servant.API (NoContent)
import           Servant.API.Generic (fromServant)
import           Servant.Client (ClientEnv(..), ClientM, client)
import           Servant.Client.Core.Request (Request, requestHeaders)
import           Servant.Client.Generic (AsClientT)

import           PowerDNS.API
import           PowerDNS.Internal.Utils (empty)

-- | Causes all requests with this 'ClientEnv' to be sent with the specified key embedded in a X-API-Key header.
applyXApiKey :: T.Text -- ^ API key
             -> ClientEnv
             -> ClientEnv
applyXApiKey :: Text -> ClientEnv -> ClientEnv
applyXApiKey Text
key ClientEnv
env = ClientEnv
env { makeClientRequest = modified }
  where
    modified :: BaseUrl -> Request -> IO Request
modified BaseUrl
url = ClientEnv -> BaseUrl -> Request -> IO Request
makeClientRequest ClientEnv
env BaseUrl
url (Request -> IO Request)
-> (Request -> Request) -> Request -> IO Request
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Request -> Request
applyXApiKeyHeader Text
key

applyXApiKeyHeader :: T.Text -> Request -> Request
applyXApiKeyHeader :: Text -> Request -> Request
applyXApiKeyHeader Text
key Request
req =
    Request
req { requestHeaders = requestHeaders req |> authHeader }
  where
    authHeader :: Header
authHeader = (ByteString -> CI ByteString
forall s. FoldCase s => s -> CI s
CI.mk ByteString
"X-API-Key", Text -> ByteString
T.encodeUtf8 Text
key)

----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------

pdnsClient :: PowerDNS (AsClientT ClientM)
pdnsClient :: PowerDNS (AsClientT ClientM)
pdnsClient = ToServant PowerDNS (AsClientT ClientM)
-> PowerDNS (AsClientT ClientM)
forall (routes :: * -> *) mode.
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant (Proxy
  ((("api" :> (Summary "List versions" :> Get '[JSON] [Version]))
    :<|> (("api"
           :> ("v1"
               :> (((Summary "List servers"
                     :> ("servers" :> Get '[JSON] [Server]))
                    :<|> (Summary "Get server"
                          :> ("servers"
                              :> (Capture "server_id" Text :> Get '[JSON] Server))))
                   :<|> ((Summary "Search"
                          :> ("servers"
                              :> (Capture "server_id" Text
                                  :> ("search-data"
                                      :> (QueryParamReq "q" Text
                                          :> (QueryParamReq "max" Integer
                                              :> (QueryParam "object_type" ObjectType
                                                  :> Get '[JSON] [SearchResult])))))))
                         :<|> ((Summary "Flush cache"
                                :> ("servers"
                                    :> (Capture "server_id" Text
                                        :> (QueryParamReq "domain" Text
                                            :> Put '[JSON] CacheFlushResult))))
                               :<|> (Summary "Statistics"
                                     :> ("servers"
                                         :> (Capture "server_id" Text
                                             :> ("statistics"
                                                 :> (QueryParam "statistic" Text
                                                     :> (QueryParam "includerings" Bool
                                                         :> Get
                                                              '[JSON] [AnyStatisticItem])))))))))))
          :<|> ("api"
                :> ("v1"
                    :> ((((Summary "List zones"
                           :> ("servers"
                               :> (Capture "server_id" Text
                                   :> ("zones"
                                       :> (QueryParam "zone" Text
                                           :> (QueryParam "dnssec" Bool :> Get '[JSON] [Zone]))))))
                          :<|> (Summary "Create zone"
                                :> ("servers"
                                    :> (Capture "server_id" Text
                                        :> ("zones"
                                            :> (QueryParam "rrset" Bool
                                                :> (ReqBody '[JSON] Zone
                                                    :> PostCreated '[JSON] Zone)))))))
                         :<|> ((Summary "Get zone"
                                :> ("servers"
                                    :> (Capture "server_id" Text
                                        :> ("zones"
                                            :> (Capture "zone_id" Text
                                                :> (QueryParam "rrsets" Bool
                                                    :> Get '[JSON] Zone))))))
                               :<|> ((Summary "Delete zone"
                                      :> ("servers"
                                          :> (Capture "server_id" Text
                                              :> ("zones"
                                                  :> (Capture "zone_id" Text :> DeleteNoContent)))))
                                     :<|> (Summary "Update records"
                                           :> ("servers"
                                               :> (Capture "server_id" Text
                                                   :> ("zones"
                                                       :> (Capture "zone_id" Text
                                                           :> (ReqBody '[JSON] RRSets
                                                               :> PatchNoContent)))))))))
                        :<|> (((Summary "Update zone"
                                :> ("servers"
                                    :> (Capture "server_id" Text
                                        :> ("zones"
                                            :> (Capture "zone_id" Text
                                                :> (ReqBody '[JSON] Zone :> PutNoContent))))))
                               :<|> (Summary "Trigger AXFR"
                                     :> ("servers"
                                         :> (Capture "server_id" Text
                                             :> ("zones"
                                                 :> (Capture "zone_id" Text
                                                     :> ("axfr-retrieve"
                                                         :> Put '[JSON] Result)))))))
                              :<|> ((Summary "Notify slaves"
                                     :> ("servers"
                                         :> (Capture "server_id" Text
                                             :> ("zones"
                                                 :> (Capture "zone_id" Text
                                                     :> ("notify" :> Put '[JSON] Result))))))
                                    :<|> ((Summary "Get zone AXFR"
                                           :> ("servers"
                                               :> (Capture "server_id" Text
                                                   :> ("zones"
                                                       :> (Capture "zone_id" Text
                                                           :> ("export" :> Get '[JSON] Result))))))
                                          :<|> (Summary "Rectify zone"
                                                :> ("servers"
                                                    :> (Capture "server_id" Text
                                                        :> ("zones"
                                                            :> (Capture "zone_id" Text
                                                                :> ("rectify"
                                                                    :> Put
                                                                         '[JSON]
                                                                         Result))))))))))))))
   :<|> (("api"
          :> ("v1"
              :> (((Summary "List cryptokeys"
                    :> ("servers"
                        :> (Capture "server_id" Text
                            :> ("zones"
                                :> (Capture "zone_id" Text
                                    :> ("cryptokeys" :> Get '[JSON] [Cryptokey]))))))
                   :<|> (Summary "Create cryptokey"
                         :> ("servers"
                             :> (Capture "server_id" Text
                                 :> ("zones"
                                     :> (Capture "zone_id" Text
                                         :> ("cryptokeys"
                                             :> (ReqBody '[JSON] Cryptokey
                                                 :> PostCreated '[JSON] Cryptokey))))))))
                  :<|> ((Summary "Get cryptokey"
                         :> ("servers"
                             :> (Capture "server_id" Text
                                 :> ("zones"
                                     :> (Capture "zone_id" Text
                                         :> ("cryptokeys"
                                             :> (Capture "cryptokey_id" Text
                                                 :> Get '[JSON] Cryptokey)))))))
                        :<|> ((Summary "Update cryptokey"
                               :> ("servers"
                                   :> (Capture "server_id" Text
                                       :> ("zones"
                                           :> (Capture "zone_id" Text
                                               :> ("cryptokeys"
                                                   :> (Capture "cryptokey_id" Text
                                                       :> (ReqBody '[JSON] Cryptokey
                                                           :> PutNoContent))))))))
                              :<|> (Summary "Delete cryptokey"
                                    :> ("servers"
                                        :> (Capture "server_id" Text
                                            :> ("zones"
                                                :> (Capture "zone_id" Text
                                                    :> ("cryptokeys"
                                                        :> (Capture "cryptokey_id" Text
                                                            :> DeleteNoContent))))))))))))
         :<|> (("api"
                :> ("v1"
                    :> (((Summary "List metadata"
                          :> ("servers"
                              :> (Capture "server_id" Text
                                  :> ("zones"
                                      :> (Capture "zone_id" Text
                                          :> ("metadata" :> Get '[JSON] [Metadata]))))))
                         :<|> (Summary "Create metadata"
                               :> ("servers"
                                   :> (Capture "server_id" Text
                                       :> ("zones"
                                           :> (Capture "zone_id" Text
                                               :> ("metadata"
                                                   :> (ReqBody '[JSON] Metadata
                                                       :> PostNoContent))))))))
                        :<|> ((Summary "Get metadata"
                               :> ("servers"
                                   :> (Capture "server_id" Text
                                       :> ("zones"
                                           :> (Capture "zone_id" Text
                                               :> ("metadata"
                                                   :> (Capture "kind" Text
                                                       :> Get '[JSON] Metadata)))))))
                              :<|> ((Summary "Update metadata"
                                     :> ("servers"
                                         :> (Capture "server_id" Text
                                             :> ("zones"
                                                 :> (Capture "zone_id" Text
                                                     :> ("metadata"
                                                         :> (Capture "kind" Text
                                                             :> (ReqBody '[JSON] Metadata
                                                                 :> Put '[JSON] Metadata))))))))
                                    :<|> (Summary "Delete metadata"
                                          :> ("servers"
                                              :> (Capture "server_id" Text
                                                  :> ("zones"
                                                      :> (Capture "zone_id" Text
                                                          :> ("metadata"
                                                              :> (Capture "kind" Text
                                                                  :> DeleteNoContent))))))))))))
               :<|> ("api"
                     :> ("v1"
                         :> (((Summary "List TSIG keys"
                               :> ("servers"
                                   :> (Capture "server_id" Text
                                       :> ("tsigkeys" :> Get '[JSON] [TSIGKey]))))
                              :<|> (Summary "Create TSIG key"
                                    :> ("servers"
                                        :> (Capture "server_id" Text
                                            :> ("tsigkeys"
                                                :> (ReqBody '[JSON] TSIGKey
                                                    :> PostCreated '[JSON] TSIGKey))))))
                             :<|> ((Summary "Get TSIG key"
                                    :> ("servers"
                                        :> (Capture "server_id" Text
                                            :> ("tsigkeys"
                                                :> (Capture "tsigkey_id" Text
                                                    :> Get '[JSON] TSIGKey)))))
                                   :<|> ((Summary "Update TSIG key"
                                          :> ("servers"
                                              :> (Capture "server_id" Text
                                                  :> ("tsigkeys"
                                                      :> (Capture "tsigkey_id" Text
                                                          :> (ReqBody '[JSON] TSIGKey
                                                              :> Put '[JSON] TSIGKey))))))
                                         :<|> (Summary "DElete TSIG key"
                                               :> ("servers"
                                                   :> (Capture "server_id" Text
                                                       :> ("tsigkeys"
                                                           :> (Capture "tsigkey_id" Text
                                                               :> DeleteNoContent)))))))))))))
-> Client
     ClientM
     ((("api" :> (Summary "List versions" :> Get '[JSON] [Version]))
       :<|> (("api"
              :> ("v1"
                  :> (((Summary "List servers"
                        :> ("servers" :> Get '[JSON] [Server]))
                       :<|> (Summary "Get server"
                             :> ("servers"
                                 :> (Capture "server_id" Text :> Get '[JSON] Server))))
                      :<|> ((Summary "Search"
                             :> ("servers"
                                 :> (Capture "server_id" Text
                                     :> ("search-data"
                                         :> (QueryParamReq "q" Text
                                             :> (QueryParamReq "max" Integer
                                                 :> (QueryParam "object_type" ObjectType
                                                     :> Get '[JSON] [SearchResult])))))))
                            :<|> ((Summary "Flush cache"
                                   :> ("servers"
                                       :> (Capture "server_id" Text
                                           :> (QueryParamReq "domain" Text
                                               :> Put '[JSON] CacheFlushResult))))
                                  :<|> (Summary "Statistics"
                                        :> ("servers"
                                            :> (Capture "server_id" Text
                                                :> ("statistics"
                                                    :> (QueryParam "statistic" Text
                                                        :> (QueryParam "includerings" Bool
                                                            :> Get
                                                                 '[JSON]
                                                                 [AnyStatisticItem])))))))))))
             :<|> ("api"
                   :> ("v1"
                       :> ((((Summary "List zones"
                              :> ("servers"
                                  :> (Capture "server_id" Text
                                      :> ("zones"
                                          :> (QueryParam "zone" Text
                                              :> (QueryParam "dnssec" Bool
                                                  :> Get '[JSON] [Zone]))))))
                             :<|> (Summary "Create zone"
                                   :> ("servers"
                                       :> (Capture "server_id" Text
                                           :> ("zones"
                                               :> (QueryParam "rrset" Bool
                                                   :> (ReqBody '[JSON] Zone
                                                       :> PostCreated '[JSON] Zone)))))))
                            :<|> ((Summary "Get zone"
                                   :> ("servers"
                                       :> (Capture "server_id" Text
                                           :> ("zones"
                                               :> (Capture "zone_id" Text
                                                   :> (QueryParam "rrsets" Bool
                                                       :> Get '[JSON] Zone))))))
                                  :<|> ((Summary "Delete zone"
                                         :> ("servers"
                                             :> (Capture "server_id" Text
                                                 :> ("zones"
                                                     :> (Capture "zone_id" Text
                                                         :> DeleteNoContent)))))
                                        :<|> (Summary "Update records"
                                              :> ("servers"
                                                  :> (Capture "server_id" Text
                                                      :> ("zones"
                                                          :> (Capture "zone_id" Text
                                                              :> (ReqBody '[JSON] RRSets
                                                                  :> PatchNoContent)))))))))
                           :<|> (((Summary "Update zone"
                                   :> ("servers"
                                       :> (Capture "server_id" Text
                                           :> ("zones"
                                               :> (Capture "zone_id" Text
                                                   :> (ReqBody '[JSON] Zone :> PutNoContent))))))
                                  :<|> (Summary "Trigger AXFR"
                                        :> ("servers"
                                            :> (Capture "server_id" Text
                                                :> ("zones"
                                                    :> (Capture "zone_id" Text
                                                        :> ("axfr-retrieve"
                                                            :> Put '[JSON] Result)))))))
                                 :<|> ((Summary "Notify slaves"
                                        :> ("servers"
                                            :> (Capture "server_id" Text
                                                :> ("zones"
                                                    :> (Capture "zone_id" Text
                                                        :> ("notify" :> Put '[JSON] Result))))))
                                       :<|> ((Summary "Get zone AXFR"
                                              :> ("servers"
                                                  :> (Capture "server_id" Text
                                                      :> ("zones"
                                                          :> (Capture "zone_id" Text
                                                              :> ("export"
                                                                  :> Get '[JSON] Result))))))
                                             :<|> (Summary "Rectify zone"
                                                   :> ("servers"
                                                       :> (Capture "server_id" Text
                                                           :> ("zones"
                                                               :> (Capture "zone_id" Text
                                                                   :> ("rectify"
                                                                       :> Put
                                                                            '[JSON]
                                                                            Result))))))))))))))
      :<|> (("api"
             :> ("v1"
                 :> (((Summary "List cryptokeys"
                       :> ("servers"
                           :> (Capture "server_id" Text
                               :> ("zones"
                                   :> (Capture "zone_id" Text
                                       :> ("cryptokeys" :> Get '[JSON] [Cryptokey]))))))
                      :<|> (Summary "Create cryptokey"
                            :> ("servers"
                                :> (Capture "server_id" Text
                                    :> ("zones"
                                        :> (Capture "zone_id" Text
                                            :> ("cryptokeys"
                                                :> (ReqBody '[JSON] Cryptokey
                                                    :> PostCreated '[JSON] Cryptokey))))))))
                     :<|> ((Summary "Get cryptokey"
                            :> ("servers"
                                :> (Capture "server_id" Text
                                    :> ("zones"
                                        :> (Capture "zone_id" Text
                                            :> ("cryptokeys"
                                                :> (Capture "cryptokey_id" Text
                                                    :> Get '[JSON] Cryptokey)))))))
                           :<|> ((Summary "Update cryptokey"
                                  :> ("servers"
                                      :> (Capture "server_id" Text
                                          :> ("zones"
                                              :> (Capture "zone_id" Text
                                                  :> ("cryptokeys"
                                                      :> (Capture "cryptokey_id" Text
                                                          :> (ReqBody '[JSON] Cryptokey
                                                              :> PutNoContent))))))))
                                 :<|> (Summary "Delete cryptokey"
                                       :> ("servers"
                                           :> (Capture "server_id" Text
                                               :> ("zones"
                                                   :> (Capture "zone_id" Text
                                                       :> ("cryptokeys"
                                                           :> (Capture "cryptokey_id" Text
                                                               :> DeleteNoContent))))))))))))
            :<|> (("api"
                   :> ("v1"
                       :> (((Summary "List metadata"
                             :> ("servers"
                                 :> (Capture "server_id" Text
                                     :> ("zones"
                                         :> (Capture "zone_id" Text
                                             :> ("metadata" :> Get '[JSON] [Metadata]))))))
                            :<|> (Summary "Create metadata"
                                  :> ("servers"
                                      :> (Capture "server_id" Text
                                          :> ("zones"
                                              :> (Capture "zone_id" Text
                                                  :> ("metadata"
                                                      :> (ReqBody '[JSON] Metadata
                                                          :> PostNoContent))))))))
                           :<|> ((Summary "Get metadata"
                                  :> ("servers"
                                      :> (Capture "server_id" Text
                                          :> ("zones"
                                              :> (Capture "zone_id" Text
                                                  :> ("metadata"
                                                      :> (Capture "kind" Text
                                                          :> Get '[JSON] Metadata)))))))
                                 :<|> ((Summary "Update metadata"
                                        :> ("servers"
                                            :> (Capture "server_id" Text
                                                :> ("zones"
                                                    :> (Capture "zone_id" Text
                                                        :> ("metadata"
                                                            :> (Capture "kind" Text
                                                                :> (ReqBody '[JSON] Metadata
                                                                    :> Put '[JSON] Metadata))))))))
                                       :<|> (Summary "Delete metadata"
                                             :> ("servers"
                                                 :> (Capture "server_id" Text
                                                     :> ("zones"
                                                         :> (Capture "zone_id" Text
                                                             :> ("metadata"
                                                                 :> (Capture "kind" Text
                                                                     :> DeleteNoContent))))))))))))
                  :<|> ("api"
                        :> ("v1"
                            :> (((Summary "List TSIG keys"
                                  :> ("servers"
                                      :> (Capture "server_id" Text
                                          :> ("tsigkeys" :> Get '[JSON] [TSIGKey]))))
                                 :<|> (Summary "Create TSIG key"
                                       :> ("servers"
                                           :> (Capture "server_id" Text
                                               :> ("tsigkeys"
                                                   :> (ReqBody '[JSON] TSIGKey
                                                       :> PostCreated '[JSON] TSIGKey))))))
                                :<|> ((Summary "Get TSIG key"
                                       :> ("servers"
                                           :> (Capture "server_id" Text
                                               :> ("tsigkeys"
                                                   :> (Capture "tsigkey_id" Text
                                                       :> Get '[JSON] TSIGKey)))))
                                      :<|> ((Summary "Update TSIG key"
                                             :> ("servers"
                                                 :> (Capture "server_id" Text
                                                     :> ("tsigkeys"
                                                         :> (Capture "tsigkey_id" Text
                                                             :> (ReqBody '[JSON] TSIGKey
                                                                 :> Put '[JSON] TSIGKey))))))
                                            :<|> (Summary "DElete TSIG key"
                                                  :> ("servers"
                                                      :> (Capture "server_id" Text
                                                          :> ("tsigkeys"
                                                              :> (Capture "tsigkey_id" Text
                                                                  :> DeleteNoContent)))))))))))))
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client Proxy
  ((("api" :> (Summary "List versions" :> Get '[JSON] [Version]))
    :<|> (("api"
           :> ("v1"
               :> (((Summary "List servers"
                     :> ("servers" :> Get '[JSON] [Server]))
                    :<|> (Summary "Get server"
                          :> ("servers"
                              :> (Capture "server_id" Text :> Get '[JSON] Server))))
                   :<|> ((Summary "Search"
                          :> ("servers"
                              :> (Capture "server_id" Text
                                  :> ("search-data"
                                      :> (QueryParamReq "q" Text
                                          :> (QueryParamReq "max" Integer
                                              :> (QueryParam "object_type" ObjectType
                                                  :> Get '[JSON] [SearchResult])))))))
                         :<|> ((Summary "Flush cache"
                                :> ("servers"
                                    :> (Capture "server_id" Text
                                        :> (QueryParamReq "domain" Text
                                            :> Put '[JSON] CacheFlushResult))))
                               :<|> (Summary "Statistics"
                                     :> ("servers"
                                         :> (Capture "server_id" Text
                                             :> ("statistics"
                                                 :> (QueryParam "statistic" Text
                                                     :> (QueryParam "includerings" Bool
                                                         :> Get
                                                              '[JSON] [AnyStatisticItem])))))))))))
          :<|> ("api"
                :> ("v1"
                    :> ((((Summary "List zones"
                           :> ("servers"
                               :> (Capture "server_id" Text
                                   :> ("zones"
                                       :> (QueryParam "zone" Text
                                           :> (QueryParam "dnssec" Bool :> Get '[JSON] [Zone]))))))
                          :<|> (Summary "Create zone"
                                :> ("servers"
                                    :> (Capture "server_id" Text
                                        :> ("zones"
                                            :> (QueryParam "rrset" Bool
                                                :> (ReqBody '[JSON] Zone
                                                    :> PostCreated '[JSON] Zone)))))))
                         :<|> ((Summary "Get zone"
                                :> ("servers"
                                    :> (Capture "server_id" Text
                                        :> ("zones"
                                            :> (Capture "zone_id" Text
                                                :> (QueryParam "rrsets" Bool
                                                    :> Get '[JSON] Zone))))))
                               :<|> ((Summary "Delete zone"
                                      :> ("servers"
                                          :> (Capture "server_id" Text
                                              :> ("zones"
                                                  :> (Capture "zone_id" Text :> DeleteNoContent)))))
                                     :<|> (Summary "Update records"
                                           :> ("servers"
                                               :> (Capture "server_id" Text
                                                   :> ("zones"
                                                       :> (Capture "zone_id" Text
                                                           :> (ReqBody '[JSON] RRSets
                                                               :> PatchNoContent)))))))))
                        :<|> (((Summary "Update zone"
                                :> ("servers"
                                    :> (Capture "server_id" Text
                                        :> ("zones"
                                            :> (Capture "zone_id" Text
                                                :> (ReqBody '[JSON] Zone :> PutNoContent))))))
                               :<|> (Summary "Trigger AXFR"
                                     :> ("servers"
                                         :> (Capture "server_id" Text
                                             :> ("zones"
                                                 :> (Capture "zone_id" Text
                                                     :> ("axfr-retrieve"
                                                         :> Put '[JSON] Result)))))))
                              :<|> ((Summary "Notify slaves"
                                     :> ("servers"
                                         :> (Capture "server_id" Text
                                             :> ("zones"
                                                 :> (Capture "zone_id" Text
                                                     :> ("notify" :> Put '[JSON] Result))))))
                                    :<|> ((Summary "Get zone AXFR"
                                           :> ("servers"
                                               :> (Capture "server_id" Text
                                                   :> ("zones"
                                                       :> (Capture "zone_id" Text
                                                           :> ("export" :> Get '[JSON] Result))))))
                                          :<|> (Summary "Rectify zone"
                                                :> ("servers"
                                                    :> (Capture "server_id" Text
                                                        :> ("zones"
                                                            :> (Capture "zone_id" Text
                                                                :> ("rectify"
                                                                    :> Put
                                                                         '[JSON]
                                                                         Result))))))))))))))
   :<|> (("api"
          :> ("v1"
              :> (((Summary "List cryptokeys"
                    :> ("servers"
                        :> (Capture "server_id" Text
                            :> ("zones"
                                :> (Capture "zone_id" Text
                                    :> ("cryptokeys" :> Get '[JSON] [Cryptokey]))))))
                   :<|> (Summary "Create cryptokey"
                         :> ("servers"
                             :> (Capture "server_id" Text
                                 :> ("zones"
                                     :> (Capture "zone_id" Text
                                         :> ("cryptokeys"
                                             :> (ReqBody '[JSON] Cryptokey
                                                 :> PostCreated '[JSON] Cryptokey))))))))
                  :<|> ((Summary "Get cryptokey"
                         :> ("servers"
                             :> (Capture "server_id" Text
                                 :> ("zones"
                                     :> (Capture "zone_id" Text
                                         :> ("cryptokeys"
                                             :> (Capture "cryptokey_id" Text
                                                 :> Get '[JSON] Cryptokey)))))))
                        :<|> ((Summary "Update cryptokey"
                               :> ("servers"
                                   :> (Capture "server_id" Text
                                       :> ("zones"
                                           :> (Capture "zone_id" Text
                                               :> ("cryptokeys"
                                                   :> (Capture "cryptokey_id" Text
                                                       :> (ReqBody '[JSON] Cryptokey
                                                           :> PutNoContent))))))))
                              :<|> (Summary "Delete cryptokey"
                                    :> ("servers"
                                        :> (Capture "server_id" Text
                                            :> ("zones"
                                                :> (Capture "zone_id" Text
                                                    :> ("cryptokeys"
                                                        :> (Capture "cryptokey_id" Text
                                                            :> DeleteNoContent))))))))))))
         :<|> (("api"
                :> ("v1"
                    :> (((Summary "List metadata"
                          :> ("servers"
                              :> (Capture "server_id" Text
                                  :> ("zones"
                                      :> (Capture "zone_id" Text
                                          :> ("metadata" :> Get '[JSON] [Metadata]))))))
                         :<|> (Summary "Create metadata"
                               :> ("servers"
                                   :> (Capture "server_id" Text
                                       :> ("zones"
                                           :> (Capture "zone_id" Text
                                               :> ("metadata"
                                                   :> (ReqBody '[JSON] Metadata
                                                       :> PostNoContent))))))))
                        :<|> ((Summary "Get metadata"
                               :> ("servers"
                                   :> (Capture "server_id" Text
                                       :> ("zones"
                                           :> (Capture "zone_id" Text
                                               :> ("metadata"
                                                   :> (Capture "kind" Text
                                                       :> Get '[JSON] Metadata)))))))
                              :<|> ((Summary "Update metadata"
                                     :> ("servers"
                                         :> (Capture "server_id" Text
                                             :> ("zones"
                                                 :> (Capture "zone_id" Text
                                                     :> ("metadata"
                                                         :> (Capture "kind" Text
                                                             :> (ReqBody '[JSON] Metadata
                                                                 :> Put '[JSON] Metadata))))))))
                                    :<|> (Summary "Delete metadata"
                                          :> ("servers"
                                              :> (Capture "server_id" Text
                                                  :> ("zones"
                                                      :> (Capture "zone_id" Text
                                                          :> ("metadata"
                                                              :> (Capture "kind" Text
                                                                  :> DeleteNoContent))))))))))))
               :<|> ("api"
                     :> ("v1"
                         :> (((Summary "List TSIG keys"
                               :> ("servers"
                                   :> (Capture "server_id" Text
                                       :> ("tsigkeys" :> Get '[JSON] [TSIGKey]))))
                              :<|> (Summary "Create TSIG key"
                                    :> ("servers"
                                        :> (Capture "server_id" Text
                                            :> ("tsigkeys"
                                                :> (ReqBody '[JSON] TSIGKey
                                                    :> PostCreated '[JSON] TSIGKey))))))
                             :<|> ((Summary "Get TSIG key"
                                    :> ("servers"
                                        :> (Capture "server_id" Text
                                            :> ("tsigkeys"
                                                :> (Capture "tsigkey_id" Text
                                                    :> Get '[JSON] TSIGKey)))))
                                   :<|> ((Summary "Update TSIG key"
                                          :> ("servers"
                                              :> (Capture "server_id" Text
                                                  :> ("tsigkeys"
                                                      :> (Capture "tsigkey_id" Text
                                                          :> (ReqBody '[JSON] TSIGKey
                                                              :> Put '[JSON] TSIGKey))))))
                                         :<|> (Summary "DElete TSIG key"
                                               :> ("servers"
                                                   :> (Capture "server_id" Text
                                                       :> ("tsigkeys"
                                                           :> (Capture "tsigkey_id" Text
                                                               :> DeleteNoContent)))))))))))))
Proxy API
api)

----------------------------------------------------------------------------------------

versionsClient :: VersionsAPI (AsClientT ClientM)
versionsClient :: VersionsAPI (AsClientT ClientM)
versionsClient = ToServant VersionsAPI (AsClientT ClientM)
-> VersionsAPI (AsClientT ClientM)
forall (routes :: * -> *) mode.
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant (PowerDNS (AsClientT ClientM)
-> AsClientT ClientM :- ("api" :> ToServantApi VersionsAPI)
forall f. PowerDNS f -> f :- ("api" :> ToServantApi VersionsAPI)
versions PowerDNS (AsClientT ClientM)
pdnsClient)

-- | List the API versions and urls from the server. This is an undocumented endpoint.
listVersions :: ClientM [Version]
listVersions :: ClientM [Version]
listVersions = VersionsAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "List versions" :> Get '[JSON] [Version])
forall f.
VersionsAPI f
-> f :- (Summary "List versions" :> Get '[JSON] [Version])
apiListVersions VersionsAPI (AsClientT ClientM)
versionsClient

----------------------------------------------------------------------------------------

zonesClient :: ZonesAPI (AsClientT ClientM)
zonesClient :: ZonesAPI (AsClientT ClientM)
zonesClient = ToServant ZonesAPI (AsClientT ClientM)
-> ZonesAPI (AsClientT ClientM)
forall (routes :: * -> *) mode.
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant (PowerDNS (AsClientT ClientM)
-> AsClientT ClientM :- ("api" :> ("v1" :> ToServantApi ZonesAPI))
forall f.
PowerDNS f -> f :- ("api" :> ("v1" :> ToServantApi ZonesAPI))
zones PowerDNS (AsClientT ClientM)
pdnsClient)

-- | List all zones for the server. See [Zones API Documentation](https://doc.powerdns.com/authoritative/http-api/zone.html#get--servers-server_id-zones)
listZones :: T.Text       -- ^ Server name
          -> Maybe T.Text -- ^ Limit to zone
          -> Maybe Bool   -- ^ Whether or not to include dnssec and edited_serial fields
          -> ClientM [Zone]
listZones :: Text -> Maybe Text -> Maybe Bool -> ClientM [Zone]
listZones = ZonesAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "List zones"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (QueryParam "zone" Text
                       :> (QueryParam "dnssec" Bool :> Get '[JSON] [Zone]))))))
forall f.
ZonesAPI f
-> f
   :- (Summary "List zones"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (QueryParam "zone" Text
                       :> (QueryParam "dnssec" Bool :> Get '[JSON] [Zone]))))))
apiListZones ZonesAPI (AsClientT ClientM)
zonesClient

-- | Create a new zone. See [Zones API Documentation](https://doc.powerdns.com/authoritative/http-api/zone.html#post--servers-server_id-zones)
--
-- 'empty' with record update syntax is useful avoid having to specify Nothing
-- for unwanted fields.
createZone :: T.Text       -- ^ Server name
           -> Maybe Bool   -- ^ Whether or not to include RRsets in the response
           -> Zone         -- ^ The zone to create
           -> ClientM Zone
createZone :: Text -> Maybe Bool -> Zone -> ClientM Zone
createZone = ZonesAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Create zone"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (QueryParam "rrset" Bool
                       :> (ReqBody '[JSON] Zone :> PostCreated '[JSON] Zone))))))
forall f.
ZonesAPI f
-> f
   :- (Summary "Create zone"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (QueryParam "rrset" Bool
                       :> (ReqBody '[JSON] Zone :> PostCreated '[JSON] Zone))))))
apiCreateZone ZonesAPI (AsClientT ClientM)
zonesClient

-- | Get details for zone. See [Zones API Documentation](https://doc.powerdns.com/authoritative/http-api/zone.html#get--servers-server_id-zones-zone_id)
getZone :: T.Text       -- ^ Server name
        -> T.Text       -- ^ Zone ID
        -> Maybe Bool   -- ^ Wheher or not to include RRsets in the response
        -> ClientM Zone
getZone :: Text -> Text -> Maybe Bool -> ClientM Zone
getZone = ZonesAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Get zone"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> (QueryParam "rrsets" Bool :> Get '[JSON] Zone))))))
forall f.
ZonesAPI f
-> f
   :- (Summary "Get zone"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> (QueryParam "rrsets" Bool :> Get '[JSON] Zone))))))
apiGetZone ZonesAPI (AsClientT ClientM)
zonesClient

-- | Delete a given zone by id. See [Zones API Documentation](https://doc.powerdns.com/authoritative/http-api/zone.html#delete--servers-server_id-zones-zone_id)
deleteZone :: T.Text       -- ^ Server name
           -> T.Text       -- ^ Zone ID
           -> ClientM NoContent
deleteZone :: Text -> Text -> ClientM NoContent
deleteZone = ZonesAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Delete zone"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones" :> (Capture "zone_id" Text :> DeleteNoContent)))))
forall f.
ZonesAPI f
-> f
   :- (Summary "Delete zone"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones" :> (Capture "zone_id" Text :> DeleteNoContent)))))
apiDeleteZone ZonesAPI (AsClientT ClientM)
zonesClient

-- | Update records of a zone. See [Zones API Documentation](https://doc.powerdns.com/authoritative/http-api/zone.html#patch--servers-server_id-zones-zone_id)
--
-- __Caution__: If rrset_records or rrset_comments is set to @Just []@ on a 'Delete' changetype,
-- this will delete all existing records or comments respectively for the domain.
updateRecords :: T.Text       -- ^ Server name
              -> T.Text       -- ^ Zone ID
              -> RRSets       -- ^ The RRsets to create, update or delete.
              -> ClientM NoContent
updateRecords :: Text -> Text -> RRSets -> ClientM NoContent
updateRecords = ZonesAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Update records"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> (ReqBody '[JSON] RRSets :> PatchNoContent))))))
forall f.
ZonesAPI f
-> f
   :- (Summary "Update records"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> (ReqBody '[JSON] RRSets :> PatchNoContent))))))
apiUpdateRecords ZonesAPI (AsClientT ClientM)
zonesClient

-- | Modify zone. See [Zones API Documentation](https://doc.powerdns.com/authoritative/http-api/zone.html#put--servers-server_id-zones-zone_id)
--
-- 'empty' with record update syntax is useful avoid having to specify Nothing
-- for unwanted fields.
updateZone :: T.Text       -- ^ Server name
           -> T.Text       -- ^ Zone ID
           -> Zone         -- ^ Patch record. Fields with Just are changed, Nothing are ignored
           -> ClientM NoContent
updateZone :: Text -> Text -> Zone -> ClientM NoContent
updateZone = ZonesAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Update zone"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> (ReqBody '[JSON] Zone :> PutNoContent))))))
forall f.
ZonesAPI f
-> f
   :- (Summary "Update zone"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> (ReqBody '[JSON] Zone :> PutNoContent))))))
apiUpdateZone ZonesAPI (AsClientT ClientM)
zonesClient

-- | Trigger zone transfer on a slave. See [Zones API Documentation](https://doc.powerdns.com/authoritative/http-api/zone.html#put--servers-server_id-zones-zone_id-axfr-retrieve)
triggerAxfr :: T.Text       -- ^ Server name
            -> T.Text       -- ^ Zone ID
            -> ClientM Result
triggerAxfr :: Text -> Text -> ClientM Result
triggerAxfr = ZonesAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Trigger AXFR"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("axfr-retrieve" :> Put '[JSON] Result))))))
forall f.
ZonesAPI f
-> f
   :- (Summary "Trigger AXFR"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("axfr-retrieve" :> Put '[JSON] Result))))))
apiTriggerAxfr ZonesAPI (AsClientT ClientM)
zonesClient

-- | Send DNS notify to slaves. See [Zones API Documentation](https://doc.powerdns.com/authoritative/http-api/zone.html#put--servers-server_id-zones-zone_id-notify)
notifySlaves :: T.Text       -- ^ Server name
             -> T.Text       -- ^ Zone ID
             -> ClientM Result
notifySlaves :: Text -> Text -> ClientM Result
notifySlaves = ZonesAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Notify slaves"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text :> ("notify" :> Put '[JSON] Result))))))
forall f.
ZonesAPI f
-> f
   :- (Summary "Notify slaves"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text :> ("notify" :> Put '[JSON] Result))))))
apiNotifySlaves ZonesAPI (AsClientT ClientM)
zonesClient

-- | Return zone in AXFR format. See [Zones API Documentation](https://doc.powerdns.com/authoritative/http-api/zone.html#get--servers-server_id-zones-zone_id-export)
getZoneAxfr :: T.Text         -- ^ Server name
            -> T.Text         -- ^ Zone ID
            -> ClientM Result -- ^ Zone in AXFR format
getZoneAxfr :: Text -> Text -> ClientM Result
getZoneAxfr = ZonesAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Get zone AXFR"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text :> ("export" :> Get '[JSON] Result))))))
forall f.
ZonesAPI f
-> f
   :- (Summary "Get zone AXFR"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text :> ("export" :> Get '[JSON] Result))))))
apiGetZoneAxfr ZonesAPI (AsClientT ClientM)
zonesClient

-- | Rectify the zone data. See [Zones API Documentation](https://doc.powerdns.com/authoritative/http-api/zone.html#put--servers-server_id-zones-zone_id-rectify)
rectifyZone :: T.Text       -- ^ Server name
            -> T.Text       -- ^ Zone ID
            -> ClientM Result
rectifyZone :: Text -> Text -> ClientM Result
rectifyZone = ZonesAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Rectify zone"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("rectify" :> Put '[JSON] Result))))))
forall f.
ZonesAPI f
-> f
   :- (Summary "Rectify zone"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("rectify" :> Put '[JSON] Result))))))
apiRectifyZone ZonesAPI (AsClientT ClientM)
zonesClient

----------------------------------------------------------------------------------------

cryptokeysClient :: CryptokeysAPI (AsClientT ClientM)
cryptokeysClient :: CryptokeysAPI (AsClientT ClientM)
cryptokeysClient = ToServant CryptokeysAPI (AsClientT ClientM)
-> CryptokeysAPI (AsClientT ClientM)
forall (routes :: * -> *) mode.
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant (PowerDNS (AsClientT ClientM)
-> AsClientT ClientM
   :- ("api" :> ("v1" :> ToServantApi CryptokeysAPI))
forall f.
PowerDNS f -> f :- ("api" :> ("v1" :> ToServantApi CryptokeysAPI))
cryptokeys PowerDNS (AsClientT ClientM)
pdnsClient)

-- | List all crypto keys. See [Cryptokeys API Documentation](https://doc.powerdns.com/authoritative/http-api/cryptokey.html#get--servers-server_id-zones-zone_id-cryptokeys)
listCryptoKeys :: T.Text -- ^ Server name
               -> T.Text -- ^ Zone ID
               -> ClientM [Cryptokey]
listCryptoKeys :: Text -> Text -> ClientM [Cryptokey]
listCryptoKeys = CryptokeysAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "List cryptokeys"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("cryptokeys" :> Get '[JSON] [Cryptokey]))))))
forall f.
CryptokeysAPI f
-> f
   :- (Summary "List cryptokeys"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("cryptokeys" :> Get '[JSON] [Cryptokey]))))))
apiListCryptokeys CryptokeysAPI (AsClientT ClientM)
cryptokeysClient

-- | Create a new crypto key. See [Cryptokeys API Documentation](https://doc.powerdns.com/authoritative/http-api/cryptokey.html#post--servers-server_id-zones-zone_id-cryptokeys)
createCryptokey :: T.Text            -- ^ Server name
                -> T.Text            -- ^ Zone ID
                -> Cryptokey         -- ^ Cryptokey to create
                -> ClientM Cryptokey -- ^ Created cryptokey
createCryptokey :: Text -> Text -> Cryptokey -> ClientM Cryptokey
createCryptokey = CryptokeysAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Create cryptokey"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("cryptokeys"
                           :> (ReqBody '[JSON] Cryptokey
                               :> PostCreated '[JSON] Cryptokey)))))))
forall f.
CryptokeysAPI f
-> f
   :- (Summary "Create cryptokey"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("cryptokeys"
                           :> (ReqBody '[JSON] Cryptokey
                               :> PostCreated '[JSON] Cryptokey)))))))
apiCreateCryptokey CryptokeysAPI (AsClientT ClientM)
cryptokeysClient

-- | Get existing crypto key. See [Cryptokeys API Documentation](https://doc.powerdns.com/authoritative/http-api/cryptokey.html#post--servers-server_id-zones-zone_id-cryptokeys)
getCryptokey :: T.Text -- ^ Server name
             -> T.Text -- ^ Zone ID
             -> T.Text -- ^ Cryptokey ID
             -> ClientM Cryptokey
getCryptokey :: Text -> Text -> Text -> ClientM Cryptokey
getCryptokey = CryptokeysAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Get cryptokey"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("cryptokeys"
                           :> (Capture "cryptokey_id" Text :> Get '[JSON] Cryptokey)))))))
forall f.
CryptokeysAPI f
-> f
   :- (Summary "Get cryptokey"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("cryptokeys"
                           :> (Capture "cryptokey_id" Text :> Get '[JSON] Cryptokey)))))))
apiGetCryptokey CryptokeysAPI (AsClientT ClientM)
cryptokeysClient

-- | Update existing crypto key. See [Cryptokeys API Documentation](https://doc.powerdns.com/authoritative/http-api/cryptokey.html#put--servers-server_id-zones-zone_id-cryptokeys-cryptokey_id)
updateCryptokey :: T.Text    -- ^ Server name
                -> T.Text    -- ^ Zone ID
                -> T.Text    -- ^ Cryptokey ID
                -> Cryptokey -- ^ Patch record. Fields with Just are changed, Nothing are ignored
                -> ClientM NoContent
updateCryptokey :: Text -> Text -> Text -> Cryptokey -> ClientM NoContent
updateCryptokey = CryptokeysAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Update cryptokey"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("cryptokeys"
                           :> (Capture "cryptokey_id" Text
                               :> (ReqBody '[JSON] Cryptokey :> PutNoContent))))))))
forall f.
CryptokeysAPI f
-> f
   :- (Summary "Update cryptokey"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("cryptokeys"
                           :> (Capture "cryptokey_id" Text
                               :> (ReqBody '[JSON] Cryptokey :> PutNoContent))))))))
apiUpdateCryptokey CryptokeysAPI (AsClientT ClientM)
cryptokeysClient

-- | Delete existing crypto key. See [Cryptokeys API Documentation](https://doc.powerdns.com/authoritative/http-api/cryptokey.html#delete--servers-server_id-zones-zone_id-cryptokeys-cryptokey_id)
deleteCryptokey :: T.Text -- ^ Server name
                -> T.Text -- ^ Zone ID
                -> T.Text -- ^ Cryptokey ID
                -> ClientM NoContent
deleteCryptokey :: Text -> Text -> Text -> ClientM NoContent
deleteCryptokey = CryptokeysAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Delete cryptokey"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("cryptokeys"
                           :> (Capture "cryptokey_id" Text :> DeleteNoContent)))))))
forall f.
CryptokeysAPI f
-> f
   :- (Summary "Delete cryptokey"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("cryptokeys"
                           :> (Capture "cryptokey_id" Text :> DeleteNoContent)))))))
apiDeleteCryptokey CryptokeysAPI (AsClientT ClientM)
cryptokeysClient

----------------------------------------------------------------------------------------
serversClient :: ServersAPI (AsClientT ClientM)
serversClient :: ServersAPI (AsClientT ClientM)
serversClient = ToServant ServersAPI (AsClientT ClientM)
-> ServersAPI (AsClientT ClientM)
forall (routes :: * -> *) mode.
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant (PowerDNS (AsClientT ClientM)
-> AsClientT ClientM
   :- ("api" :> ("v1" :> ToServantApi ServersAPI))
forall f.
PowerDNS f -> f :- ("api" :> ("v1" :> ToServantApi ServersAPI))
servers PowerDNS (AsClientT ClientM)
pdnsClient)

-- | List available servers. See [Servers API Documentation](https://doc.powerdns.com/authoritative/http-api/server.html#get--servers)
listServers :: ClientM [Server]
listServers :: ClientM [Server]
listServers = ServersAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "List servers" :> ("servers" :> Get '[JSON] [Server]))
forall f.
ServersAPI f
-> f
   :- (Summary "List servers" :> ("servers" :> Get '[JSON] [Server]))
apiListServers ServersAPI (AsClientT ClientM)
serversClient

-- | Get existing server. See [Servers API Documentation](https://doc.powerdns.com/authoritative/http-api/server.html#get--servers-server_id)
getServer :: T.Text -- ^ Server ID
          -> ClientM Server
getServer :: Text -> ClientM Server
getServer = ServersAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Get server"
       :> ("servers" :> (Capture "server_id" Text :> Get '[JSON] Server)))
forall f.
ServersAPI f
-> f
   :- (Summary "Get server"
       :> ("servers" :> (Capture "server_id" Text :> Get '[JSON] Server)))
apiGetServer ServersAPI (AsClientT ClientM)
serversClient

-- | Searches in various object types for an arbitrary string. See [Search API Documentation](https://doc.powerdns.com/authoritative/http-api/search.html#get--servers-server_id-search-data)
search :: T.Text           -- ^ Server ID
       -> T.Text           -- ^ String to search for
       -> Integer          -- ^ Maximum number of results
       -> Maybe ObjectType -- ^ Limit results to specified object type, if any.
       -> ClientM [SearchResult]
search :: Text
-> Text -> Integer -> Maybe ObjectType -> ClientM [SearchResult]
search = ServersAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Search"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("search-data"
                   :> (QueryParamReq "q" Text
                       :> (QueryParamReq "max" Integer
                           :> (QueryParam "object_type" ObjectType
                               :> Get '[JSON] [SearchResult])))))))
forall f.
ServersAPI f
-> f
   :- (Summary "Search"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("search-data"
                   :> (QueryParamReq "q" Text
                       :> (QueryParamReq "max" Integer
                           :> (QueryParam "object_type" ObjectType
                               :> Get '[JSON] [SearchResult])))))))
apiSearch ServersAPI (AsClientT ClientM)
serversClient

-- | Flushes a domain from the cache. See [Cache API Documentation](https://doc.powerdns.com/authoritative/http-api/cache.html#put--servers-server_id-cache-flush)
flushCache :: T.Text -- ^ Server ID
           -> T.Text -- ^ Domain
           -> ClientM CacheFlushResult
flushCache :: Text -> Text -> ClientM CacheFlushResult
flushCache = ServersAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Flush cache"
       :> ("servers"
           :> (Capture "server_id" Text
               :> (QueryParamReq "domain" Text :> Put '[JSON] CacheFlushResult))))
forall f.
ServersAPI f
-> f
   :- (Summary "Flush cache"
       :> ("servers"
           :> (Capture "server_id" Text
               :> (QueryParamReq "domain" Text :> Put '[JSON] CacheFlushResult))))
apiFlushCache ServersAPI (AsClientT ClientM)
serversClient

-- | Get server wide statistics. See [Cache API Documentation](https://doc.powerdns.com/authoritative/http-api/statistics.html)
statistics :: T.Text       -- ^ Server ID
           -> Maybe T.Text -- ^ Only return statistic items with this name.
           -> Maybe Bool   -- ^ Whether or not to return ring items.
           -> ClientM [AnyStatisticItem]
statistics :: Text -> Maybe Text -> Maybe Bool -> ClientM [AnyStatisticItem]
statistics = ServersAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Statistics"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("statistics"
                   :> (QueryParam "statistic" Text
                       :> (QueryParam "includerings" Bool
                           :> Get '[JSON] [AnyStatisticItem]))))))
forall f.
ServersAPI f
-> f
   :- (Summary "Statistics"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("statistics"
                   :> (QueryParam "statistic" Text
                       :> (QueryParam "includerings" Bool
                           :> Get '[JSON] [AnyStatisticItem]))))))
apiStatistics ServersAPI (AsClientT ClientM)
serversClient

----------------------------------------------------------------------------------------
metadataClient :: MetadataAPI (AsClientT ClientM)
metadataClient :: MetadataAPI (AsClientT ClientM)
metadataClient = ToServant MetadataAPI (AsClientT ClientM)
-> MetadataAPI (AsClientT ClientM)
forall (routes :: * -> *) mode.
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant (PowerDNS (AsClientT ClientM)
-> AsClientT ClientM
   :- ("api" :> ("v1" :> ToServantApi MetadataAPI))
forall f.
PowerDNS f -> f :- ("api" :> ("v1" :> ToServantApi MetadataAPI))
metadata PowerDNS (AsClientT ClientM)
pdnsClient)

-- | List metadata for existing zone. See [Metadata API Documentation](https://doc.powerdns.com/authoritative/http-api/metadata.html#get--servers-server_id-zones-zone_id-metadata)
listMetadata :: T.Text -- ^ Server ID
             -> T.Text -- ^ Zone ID
             -> ClientM [Metadata]
listMetadata :: Text -> Text -> ClientM [Metadata]
listMetadata = MetadataAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "List metadata"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("metadata" :> Get '[JSON] [Metadata]))))))
forall f.
MetadataAPI f
-> f
   :- (Summary "List metadata"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("metadata" :> Get '[JSON] [Metadata]))))))
apiListMetadata MetadataAPI (AsClientT ClientM)
metadataClient

-- | Create metadata for zone. See [Metadata API Documentation](https://doc.powerdns.com/authoritative/http-api/metadata.html#post--servers-server_id-zones-zone_id-metadata)
createMetadata :: T.Text -- ^ Server ID
               -> T.Text -- ^ Zone ID
               -> Metadata
               -> ClientM NoContent
createMetadata :: Text -> Text -> Metadata -> ClientM NoContent
createMetadata = MetadataAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Create metadata"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("metadata" :> (ReqBody '[JSON] Metadata :> PostNoContent)))))))
forall f.
MetadataAPI f
-> f
   :- (Summary "Create metadata"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("metadata" :> (ReqBody '[JSON] Metadata :> PostNoContent)))))))
apiCreateMetadata MetadataAPI (AsClientT ClientM)
metadataClient

-- | Get metadata for zone by kind. See [Metadata API Documentation](https://doc.powerdns.com/authoritative/http-api/metadata.html#get--servers-server_id-zones-zone_id-metadata-metadata_kind)
getMetadata :: T.Text -- ^ Server ID
            -> T.Text -- ^ Zone ID
            -> T.Text -- ^ Kind
            -> ClientM Metadata
getMetadata :: Text -> Text -> Text -> ClientM Metadata
getMetadata = MetadataAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Get metadata"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("metadata"
                           :> (Capture "kind" Text :> Get '[JSON] Metadata)))))))
forall f.
MetadataAPI f
-> f
   :- (Summary "Get metadata"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("metadata"
                           :> (Capture "kind" Text :> Get '[JSON] Metadata)))))))
apiGetMetadata MetadataAPI (AsClientT ClientM)
metadataClient

-- | Update metadata for zone by kind. See [Metadata API Documentation](https://doc.powerdns.com/authoritative/http-api/metadata.html#put--servers-server_id-zones-zone_id-metadata-metadata_kind)
updateMetadata :: T.Text -- ^ Server ID
               -> T.Text -- ^ Zone ID
               -> T.Text -- ^ Kind
               -> Metadata
               -> ClientM Metadata
updateMetadata :: Text -> Text -> Text -> Metadata -> ClientM Metadata
updateMetadata = MetadataAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Update metadata"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("metadata"
                           :> (Capture "kind" Text
                               :> (ReqBody '[JSON] Metadata :> Put '[JSON] Metadata))))))))
forall f.
MetadataAPI f
-> f
   :- (Summary "Update metadata"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("metadata"
                           :> (Capture "kind" Text
                               :> (ReqBody '[JSON] Metadata :> Put '[JSON] Metadata))))))))
apiUpdateMetadata MetadataAPI (AsClientT ClientM)
metadataClient

-- | Delete metadata for zone by kind. See [Metadata API Documentation](https://doc.powerdns.com/authoritative/http-api/metadata.html#delete--servers-server_id-zones-zone_id-metadata-metadata_kind)
deleteMetadata :: T.Text -- ^ Server ID
               -> T.Text -- ^ Zone ID
               -> T.Text -- ^ Kind
               -> ClientM NoContent
deleteMetadata :: Text -> Text -> Text -> ClientM NoContent
deleteMetadata = MetadataAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Delete metadata"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("metadata" :> (Capture "kind" Text :> DeleteNoContent)))))))
forall f.
MetadataAPI f
-> f
   :- (Summary "Delete metadata"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("zones"
                   :> (Capture "zone_id" Text
                       :> ("metadata" :> (Capture "kind" Text :> DeleteNoContent)))))))
apiDeleteMetadata MetadataAPI (AsClientT ClientM)
metadataClient

----------------------------------------------------------------------------------------
tsigkeysClient :: TSIGKeysAPI (AsClientT ClientM)
tsigkeysClient :: TSIGKeysAPI (AsClientT ClientM)
tsigkeysClient = ToServant TSIGKeysAPI (AsClientT ClientM)
-> TSIGKeysAPI (AsClientT ClientM)
forall (routes :: * -> *) mode.
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant (PowerDNS (AsClientT ClientM)
-> AsClientT ClientM
   :- ("api" :> ("v1" :> ToServantApi TSIGKeysAPI))
forall f.
PowerDNS f -> f :- ("api" :> ("v1" :> ToServantApi TSIGKeysAPI))
tsigkeys PowerDNS (AsClientT ClientM)
pdnsClient)

-- | List all TSIG keys. See [TSIGKeys API Documentation](https://doc.powerdns.com/authoritative/http-api/tsigkey.html#get--servers-server_id-tsigkeys)
listTSIGKeys :: T.Text -> ClientM [TSIGKey]
listTSIGKeys :: Text -> ClientM [TSIGKey]
listTSIGKeys = TSIGKeysAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "List TSIG keys"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("tsigkeys" :> Get '[JSON] [TSIGKey]))))
forall f.
TSIGKeysAPI f
-> f
   :- (Summary "List TSIG keys"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("tsigkeys" :> Get '[JSON] [TSIGKey]))))
apiListTSIGKeys TSIGKeysAPI (AsClientT ClientM)
tsigkeysClient

-- | Create a new TSIG key. If the key is left empty, the server will generate one. See [TSIGKeys API Documentation](https://doc.powerdns.com/authoritative/http-api/tsigkey.html#post--servers-server_id-tsigkeys)
createTSIGKey :: T.Text -> TSIGKey -> ClientM TSIGKey
createTSIGKey :: Text -> TSIGKey -> ClientM TSIGKey
createTSIGKey = TSIGKeysAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Create TSIG key"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("tsigkeys"
                   :> (ReqBody '[JSON] TSIGKey :> PostCreated '[JSON] TSIGKey)))))
forall f.
TSIGKeysAPI f
-> f
   :- (Summary "Create TSIG key"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("tsigkeys"
                   :> (ReqBody '[JSON] TSIGKey :> PostCreated '[JSON] TSIGKey)))))
apiCreateTSIGKey TSIGKeysAPI (AsClientT ClientM)
tsigkeysClient

-- | Get TSIG key by its id. See [TSIGKeys API Documentation](https://doc.powerdns.com/authoritative/http-api/tsigkey.html#get--servers-server_id-tsigkeys-tsigkey_id)
getTSIGKey :: T.Text -> T.Text -> ClientM TSIGKey
getTSIGKey :: Text -> Text -> ClientM TSIGKey
getTSIGKey = TSIGKeysAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Get TSIG key"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("tsigkeys"
                   :> (Capture "tsigkey_id" Text :> Get '[JSON] TSIGKey)))))
forall f.
TSIGKeysAPI f
-> f
   :- (Summary "Get TSIG key"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("tsigkeys"
                   :> (Capture "tsigkey_id" Text :> Get '[JSON] TSIGKey)))))
apiGetTSIGKey TSIGKeysAPI (AsClientT ClientM)
tsigkeysClient

-- | Update existig TSIG key. See [TSIGKeys API Documentation](https://doc.powerdns.com/authoritative/http-api/tsigkey.html#put--servers-server_id-tsigkeys-tsigkey_id)
updateTSIGKey :: T.Text -> T.Text -> TSIGKey -> ClientM TSIGKey
updateTSIGKey :: Text -> Text -> TSIGKey -> ClientM TSIGKey
updateTSIGKey = TSIGKeysAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "Update TSIG key"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("tsigkeys"
                   :> (Capture "tsigkey_id" Text
                       :> (ReqBody '[JSON] TSIGKey :> Put '[JSON] TSIGKey))))))
forall f.
TSIGKeysAPI f
-> f
   :- (Summary "Update TSIG key"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("tsigkeys"
                   :> (Capture "tsigkey_id" Text
                       :> (ReqBody '[JSON] TSIGKey :> Put '[JSON] TSIGKey))))))
apiUpdateTSIGKey TSIGKeysAPI (AsClientT ClientM)
tsigkeysClient

-- | Delete existing TSIG key. See [TSIGKeys API Documentation](https://doc.powerdns.com/authoritative/http-api/tsigkey.html#delete--servers-server_id-tsigkeys-tsigkey_id)
deleteTSIGKey :: T.Text -> T.Text -> ClientM NoContent
deleteTSIGKey :: Text -> Text -> ClientM NoContent
deleteTSIGKey = TSIGKeysAPI (AsClientT ClientM)
-> AsClientT ClientM
   :- (Summary "DElete TSIG key"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("tsigkeys"
                   :> (Capture "tsigkey_id" Text :> DeleteNoContent)))))
forall f.
TSIGKeysAPI f
-> f
   :- (Summary "DElete TSIG key"
       :> ("servers"
           :> (Capture "server_id" Text
               :> ("tsigkeys"
                   :> (Capture "tsigkey_id" Text :> DeleteNoContent)))))
apiDeleteTSIGKey TSIGKeysAPI (AsClientT ClientM)
tsigkeysClient

----------------------------------------------------------------------------------------