{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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 :: (Service -> Service) -> ListDomainNames -> Request ListDomainNames
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListDomainNames
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDomainNames)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> 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'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"DomainNames"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall k v.
(Eq k, Hashable k, FromText k, FromXML v) =>
Text -> Text -> Text -> [Node] -> Either String (HashMap k v)
Data.parseXMLMap Text
"entry" Text
"key" Text
"value")
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListDomainNames where
  hashWithSalt :: Int -> ListDomainNames -> Int
hashWithSalt Int
_salt ListDomainNames
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData ListDomainNames where
  rnf :: ListDomainNames -> ()
rnf ListDomainNames
_ = ()

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

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

instance Data.ToQuery ListDomainNames where
  toQuery :: ListDomainNames -> QueryString
toQuery =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ ByteString
"Action"
              forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"ListDomainNames" :: Prelude.ByteString),
            ByteString
"Version"
              forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (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
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]
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
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. 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'
    { $sel:domainNames:ListDomainNamesResponse' :: Maybe (HashMap Text Text)
domainNames =
        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 :: Lens' ListDomainNamesResponse (Maybe (HashMap Text Text))
listDomainNamesResponse_domainNames = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' ListDomainNamesResponse Int
listDomainNamesResponse_httpStatus = 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 where
  rnf :: ListDomainNamesResponse -> ()
rnf ListDomainNamesResponse' {Int
Maybe (HashMap Text Text)
httpStatus :: Int
domainNames :: Maybe (HashMap Text Text)
$sel:httpStatus:ListDomainNamesResponse' :: ListDomainNamesResponse -> Int
$sel:domainNames:ListDomainNamesResponse' :: ListDomainNamesResponse -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
domainNames
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus