{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CloudSearch.ListDomainNames
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists all search domains owned by an account.
module Amazonka.CloudSearch.ListDomainNames
  ( -- * Creating a Request
    ListDomainNames (..),
    newListDomainNames,

    -- * Destructuring the Response
    ListDomainNamesResponse (..),
    newListDomainNamesResponse,

    -- * Response Lenses
    listDomainNamesResponse_domainNames,
    listDomainNamesResponse_httpStatus,
  )
where

import Amazonka.CloudSearch.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListDomainNames' smart constructor.
data ListDomainNames = ListDomainNames'
  {
  }
  deriving (ListDomainNames -> ListDomainNames -> Bool
(ListDomainNames -> ListDomainNames -> Bool)
-> (ListDomainNames -> ListDomainNames -> Bool)
-> Eq ListDomainNames
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDomainNames -> ListDomainNames -> Bool
$c/= :: ListDomainNames -> ListDomainNames -> Bool
== :: ListDomainNames -> ListDomainNames -> Bool
$c== :: ListDomainNames -> ListDomainNames -> Bool
Prelude.Eq, ReadPrec [ListDomainNames]
ReadPrec ListDomainNames
Int -> ReadS ListDomainNames
ReadS [ListDomainNames]
(Int -> ReadS ListDomainNames)
-> ReadS [ListDomainNames]
-> ReadPrec ListDomainNames
-> ReadPrec [ListDomainNames]
-> Read ListDomainNames
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDomainNames]
$creadListPrec :: ReadPrec [ListDomainNames]
readPrec :: ReadPrec ListDomainNames
$creadPrec :: ReadPrec ListDomainNames
readList :: ReadS [ListDomainNames]
$creadList :: ReadS [ListDomainNames]
readsPrec :: Int -> ReadS ListDomainNames
$creadsPrec :: Int -> ReadS ListDomainNames
Prelude.Read, Int -> ListDomainNames -> ShowS
[ListDomainNames] -> ShowS
ListDomainNames -> String
(Int -> ListDomainNames -> ShowS)
-> (ListDomainNames -> String)
-> ([ListDomainNames] -> ShowS)
-> Show ListDomainNames
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDomainNames] -> ShowS
$cshowList :: [ListDomainNames] -> ShowS
show :: ListDomainNames -> String
$cshow :: ListDomainNames -> String
showsPrec :: Int -> ListDomainNames -> ShowS
$cshowsPrec :: Int -> ListDomainNames -> ShowS
Prelude.Show, (forall x. ListDomainNames -> Rep ListDomainNames x)
-> (forall x. Rep ListDomainNames x -> ListDomainNames)
-> Generic ListDomainNames
forall x. Rep ListDomainNames x -> ListDomainNames
forall x. ListDomainNames -> Rep ListDomainNames x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDomainNames x -> ListDomainNames
$cfrom :: forall x. ListDomainNames -> Rep ListDomainNames x
Prelude.Generic)

-- |
-- Create a value of 'ListDomainNames' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
newListDomainNames ::
  ListDomainNames
newListDomainNames :: ListDomainNames
newListDomainNames = ListDomainNames
ListDomainNames'

instance Core.AWSRequest ListDomainNames where
  type
    AWSResponse ListDomainNames =
      ListDomainNamesResponse
  request :: ListDomainNames -> Request ListDomainNames
request = Service -> ListDomainNames -> Request ListDomainNames
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ListDomainNames
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDomainNames)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ListDomainNames))
-> Logger
-> Service
-> Proxy ListDomainNames
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDomainNames)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ListDomainNamesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe (HashMap Text Text) -> Int -> ListDomainNamesResponse
ListDomainNamesResponse'
            (Maybe (HashMap Text Text) -> Int -> ListDomainNamesResponse)
-> Either String (Maybe (HashMap Text Text))
-> Either String (Int -> ListDomainNamesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DomainNames" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe (HashMap Text Text)))
-> Either String (Maybe (HashMap Text Text))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String (HashMap Text Text))
-> [Node] -> Either String (Maybe (HashMap Text Text))
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> Text -> Text -> [Node] -> Either String (HashMap Text Text)
forall k v.
(Eq k, Hashable k, FromText k, FromXML v) =>
Text -> Text -> Text -> [Node] -> Either String (HashMap k v)
Core.parseXMLMap Text
"entry" Text
"key" Text
"value")
                        )
            Either String (Int -> ListDomainNamesResponse)
-> Either String Int -> Either String ListDomainNamesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListDomainNames

instance Prelude.NFData ListDomainNames

instance Core.ToHeaders ListDomainNames where
  toHeaders :: ListDomainNames -> ResponseHeaders
toHeaders = ResponseHeaders -> ListDomainNames -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath ListDomainNames where
  toPath :: ListDomainNames -> ByteString
toPath = ByteString -> ListDomainNames -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ListDomainNames where
  toQuery :: ListDomainNames -> QueryString
toQuery =
    QueryString -> ListDomainNames -> QueryString
forall a b. a -> b -> a
Prelude.const
      ( [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ ByteString
"Action"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"ListDomainNames" :: Prelude.ByteString),
            ByteString
"Version"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2013-01-01" :: Prelude.ByteString)
          ]
      )

-- | The result of a @ListDomainNames@ request. Contains a list of the
-- domains owned by an account.
--
-- /See:/ 'newListDomainNamesResponse' smart constructor.
data ListDomainNamesResponse = ListDomainNamesResponse'
  { -- | The names of the search domains owned by an account.
    ListDomainNamesResponse -> Maybe (HashMap Text Text)
domainNames :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The response's http status code.
    ListDomainNamesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDomainNamesResponse -> ListDomainNamesResponse -> Bool
(ListDomainNamesResponse -> ListDomainNamesResponse -> Bool)
-> (ListDomainNamesResponse -> ListDomainNamesResponse -> Bool)
-> Eq ListDomainNamesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDomainNamesResponse -> ListDomainNamesResponse -> Bool
$c/= :: ListDomainNamesResponse -> ListDomainNamesResponse -> Bool
== :: ListDomainNamesResponse -> ListDomainNamesResponse -> Bool
$c== :: ListDomainNamesResponse -> ListDomainNamesResponse -> Bool
Prelude.Eq, ReadPrec [ListDomainNamesResponse]
ReadPrec ListDomainNamesResponse
Int -> ReadS ListDomainNamesResponse
ReadS [ListDomainNamesResponse]
(Int -> ReadS ListDomainNamesResponse)
-> ReadS [ListDomainNamesResponse]
-> ReadPrec ListDomainNamesResponse
-> ReadPrec [ListDomainNamesResponse]
-> Read ListDomainNamesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDomainNamesResponse]
$creadListPrec :: ReadPrec [ListDomainNamesResponse]
readPrec :: ReadPrec ListDomainNamesResponse
$creadPrec :: ReadPrec ListDomainNamesResponse
readList :: ReadS [ListDomainNamesResponse]
$creadList :: ReadS [ListDomainNamesResponse]
readsPrec :: Int -> ReadS ListDomainNamesResponse
$creadsPrec :: Int -> ReadS ListDomainNamesResponse
Prelude.Read, Int -> ListDomainNamesResponse -> ShowS
[ListDomainNamesResponse] -> ShowS
ListDomainNamesResponse -> String
(Int -> ListDomainNamesResponse -> ShowS)
-> (ListDomainNamesResponse -> String)
-> ([ListDomainNamesResponse] -> ShowS)
-> Show ListDomainNamesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDomainNamesResponse] -> ShowS
$cshowList :: [ListDomainNamesResponse] -> ShowS
show :: ListDomainNamesResponse -> String
$cshow :: ListDomainNamesResponse -> String
showsPrec :: Int -> ListDomainNamesResponse -> ShowS
$cshowsPrec :: Int -> ListDomainNamesResponse -> ShowS
Prelude.Show, (forall x.
 ListDomainNamesResponse -> Rep ListDomainNamesResponse x)
-> (forall x.
    Rep ListDomainNamesResponse x -> ListDomainNamesResponse)
-> Generic ListDomainNamesResponse
forall x. Rep ListDomainNamesResponse x -> ListDomainNamesResponse
forall x. ListDomainNamesResponse -> Rep ListDomainNamesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDomainNamesResponse x -> ListDomainNamesResponse
$cfrom :: forall x. ListDomainNamesResponse -> Rep ListDomainNamesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDomainNamesResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'domainNames', 'listDomainNamesResponse_domainNames' - The names of the search domains owned by an account.
--
-- 'httpStatus', 'listDomainNamesResponse_httpStatus' - The response's http status code.
newListDomainNamesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDomainNamesResponse
newListDomainNamesResponse :: Int -> ListDomainNamesResponse
newListDomainNamesResponse Int
pHttpStatus_ =
  ListDomainNamesResponse' :: Maybe (HashMap Text Text) -> Int -> ListDomainNamesResponse
ListDomainNamesResponse'
    { $sel:domainNames:ListDomainNamesResponse' :: Maybe (HashMap Text Text)
domainNames =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDomainNamesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The names of the search domains owned by an account.
listDomainNamesResponse_domainNames :: Lens.Lens' ListDomainNamesResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
listDomainNamesResponse_domainNames :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ListDomainNamesResponse -> f ListDomainNamesResponse
listDomainNamesResponse_domainNames = (ListDomainNamesResponse -> Maybe (HashMap Text Text))
-> (ListDomainNamesResponse
    -> Maybe (HashMap Text Text) -> ListDomainNamesResponse)
-> Lens
     ListDomainNamesResponse
     ListDomainNamesResponse
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDomainNamesResponse' {Maybe (HashMap Text Text)
domainNames :: Maybe (HashMap Text Text)
$sel:domainNames:ListDomainNamesResponse' :: ListDomainNamesResponse -> Maybe (HashMap Text Text)
domainNames} -> Maybe (HashMap Text Text)
domainNames) (\s :: ListDomainNamesResponse
s@ListDomainNamesResponse' {} Maybe (HashMap Text Text)
a -> ListDomainNamesResponse
s {$sel:domainNames:ListDomainNamesResponse' :: Maybe (HashMap Text Text)
domainNames = Maybe (HashMap Text Text)
a} :: ListDomainNamesResponse) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ListDomainNamesResponse -> f ListDomainNamesResponse)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ListDomainNamesResponse
-> f ListDomainNamesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
listDomainNamesResponse_httpStatus :: Lens.Lens' ListDomainNamesResponse Prelude.Int
listDomainNamesResponse_httpStatus :: (Int -> f Int)
-> ListDomainNamesResponse -> f ListDomainNamesResponse
listDomainNamesResponse_httpStatus = (ListDomainNamesResponse -> Int)
-> (ListDomainNamesResponse -> Int -> ListDomainNamesResponse)
-> Lens ListDomainNamesResponse ListDomainNamesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDomainNamesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListDomainNamesResponse' :: ListDomainNamesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListDomainNamesResponse
s@ListDomainNamesResponse' {} Int
a -> ListDomainNamesResponse
s {$sel:httpStatus:ListDomainNamesResponse' :: Int
httpStatus = Int
a} :: ListDomainNamesResponse)

instance Prelude.NFData ListDomainNamesResponse