{-# 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.SWF.DescribeDomain
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns information about the specified domain, including description
-- and status.
--
-- __Access Control__
--
-- You can use IAM policies to control this action\'s access to Amazon SWF
-- resources as follows:
--
-- -   Use a @Resource@ element with the domain name to limit the action to
--     only specified domains.
--
-- -   Use an @Action@ element to allow or deny permission to call this
--     action.
--
-- -   You cannot use an IAM policy to constrain this action\'s parameters.
--
-- If the caller doesn\'t have sufficient permissions to invoke the action,
-- or the parameter values fall outside the specified constraints, the
-- action fails. The associated event attribute\'s @cause@ parameter is set
-- to @OPERATION_NOT_PERMITTED@. For details and example IAM policies, see
-- <https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html Using IAM to Manage Access to Amazon SWF Workflows>
-- in the /Amazon SWF Developer Guide/.
module Amazonka.SWF.DescribeDomain
  ( -- * Creating a Request
    DescribeDomain (..),
    newDescribeDomain,

    -- * Request Lenses
    describeDomain_name,

    -- * Destructuring the Response
    DescribeDomainResponse (..),
    newDescribeDomainResponse,

    -- * Response Lenses
    describeDomainResponse_httpStatus,
    describeDomainResponse_domainInfo,
    describeDomainResponse_configuration,
  )
where

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
import Amazonka.SWF.Types

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

-- |
-- Create a value of 'DescribeDomain' 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:
--
-- 'name', 'describeDomain_name' - The name of the domain to describe.
newDescribeDomain ::
  -- | 'name'
  Prelude.Text ->
  DescribeDomain
newDescribeDomain :: Text -> DescribeDomain
newDescribeDomain Text
pName_ =
  DescribeDomain' {$sel:name:DescribeDomain' :: Text
name = Text
pName_}

-- | The name of the domain to describe.
describeDomain_name :: Lens.Lens' DescribeDomain Prelude.Text
describeDomain_name :: Lens' DescribeDomain Text
describeDomain_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDomain' {Text
name :: Text
$sel:name:DescribeDomain' :: DescribeDomain -> Text
name} -> Text
name) (\s :: DescribeDomain
s@DescribeDomain' {} Text
a -> DescribeDomain
s {$sel:name:DescribeDomain' :: Text
name = Text
a} :: DescribeDomain)

instance Core.AWSRequest DescribeDomain where
  type
    AWSResponse DescribeDomain =
      DescribeDomainResponse
  request :: (Service -> Service) -> DescribeDomain -> Request DescribeDomain
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeDomain
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeDomain)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> DomainInfo -> DomainConfiguration -> DescribeDomainResponse
DescribeDomainResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"domainInfo")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"configuration")
      )

instance Prelude.Hashable DescribeDomain where
  hashWithSalt :: Int -> DescribeDomain -> Int
hashWithSalt Int
_salt DescribeDomain' {Text
name :: Text
$sel:name:DescribeDomain' :: DescribeDomain -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData DescribeDomain where
  rnf :: DescribeDomain -> ()
rnf DescribeDomain' {Text
name :: Text
$sel:name:DescribeDomain' :: DescribeDomain -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders DescribeDomain where
  toHeaders :: DescribeDomain -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"SimpleWorkflowService.DescribeDomain" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DescribeDomain where
  toJSON :: DescribeDomain -> Value
toJSON DescribeDomain' {Text
name :: Text
$sel:name:DescribeDomain' :: DescribeDomain -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)]
      )

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

instance Data.ToQuery DescribeDomain where
  toQuery :: DescribeDomain -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | Contains details of a domain.
--
-- /See:/ 'newDescribeDomainResponse' smart constructor.
data DescribeDomainResponse = DescribeDomainResponse'
  { -- | The response's http status code.
    DescribeDomainResponse -> Int
httpStatus :: Prelude.Int,
    -- | The basic information about a domain, such as its name, status, and
    -- description.
    DescribeDomainResponse -> DomainInfo
domainInfo :: DomainInfo,
    -- | The domain configuration. Currently, this includes only the domain\'s
    -- retention period.
    DescribeDomainResponse -> DomainConfiguration
configuration :: DomainConfiguration
  }
  deriving (DescribeDomainResponse -> DescribeDomainResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDomainResponse -> DescribeDomainResponse -> Bool
$c/= :: DescribeDomainResponse -> DescribeDomainResponse -> Bool
== :: DescribeDomainResponse -> DescribeDomainResponse -> Bool
$c== :: DescribeDomainResponse -> DescribeDomainResponse -> Bool
Prelude.Eq, ReadPrec [DescribeDomainResponse]
ReadPrec DescribeDomainResponse
Int -> ReadS DescribeDomainResponse
ReadS [DescribeDomainResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeDomainResponse]
$creadListPrec :: ReadPrec [DescribeDomainResponse]
readPrec :: ReadPrec DescribeDomainResponse
$creadPrec :: ReadPrec DescribeDomainResponse
readList :: ReadS [DescribeDomainResponse]
$creadList :: ReadS [DescribeDomainResponse]
readsPrec :: Int -> ReadS DescribeDomainResponse
$creadsPrec :: Int -> ReadS DescribeDomainResponse
Prelude.Read, Int -> DescribeDomainResponse -> ShowS
[DescribeDomainResponse] -> ShowS
DescribeDomainResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDomainResponse] -> ShowS
$cshowList :: [DescribeDomainResponse] -> ShowS
show :: DescribeDomainResponse -> String
$cshow :: DescribeDomainResponse -> String
showsPrec :: Int -> DescribeDomainResponse -> ShowS
$cshowsPrec :: Int -> DescribeDomainResponse -> ShowS
Prelude.Show, forall x. Rep DescribeDomainResponse x -> DescribeDomainResponse
forall x. DescribeDomainResponse -> Rep DescribeDomainResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeDomainResponse x -> DescribeDomainResponse
$cfrom :: forall x. DescribeDomainResponse -> Rep DescribeDomainResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeDomainResponse' 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:
--
-- 'httpStatus', 'describeDomainResponse_httpStatus' - The response's http status code.
--
-- 'domainInfo', 'describeDomainResponse_domainInfo' - The basic information about a domain, such as its name, status, and
-- description.
--
-- 'configuration', 'describeDomainResponse_configuration' - The domain configuration. Currently, this includes only the domain\'s
-- retention period.
newDescribeDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'domainInfo'
  DomainInfo ->
  -- | 'configuration'
  DomainConfiguration ->
  DescribeDomainResponse
newDescribeDomainResponse :: Int -> DomainInfo -> DomainConfiguration -> DescribeDomainResponse
newDescribeDomainResponse
  Int
pHttpStatus_
  DomainInfo
pDomainInfo_
  DomainConfiguration
pConfiguration_ =
    DescribeDomainResponse'
      { $sel:httpStatus:DescribeDomainResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:domainInfo:DescribeDomainResponse' :: DomainInfo
domainInfo = DomainInfo
pDomainInfo_,
        $sel:configuration:DescribeDomainResponse' :: DomainConfiguration
configuration = DomainConfiguration
pConfiguration_
      }

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

-- | The basic information about a domain, such as its name, status, and
-- description.
describeDomainResponse_domainInfo :: Lens.Lens' DescribeDomainResponse DomainInfo
describeDomainResponse_domainInfo :: Lens' DescribeDomainResponse DomainInfo
describeDomainResponse_domainInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDomainResponse' {DomainInfo
domainInfo :: DomainInfo
$sel:domainInfo:DescribeDomainResponse' :: DescribeDomainResponse -> DomainInfo
domainInfo} -> DomainInfo
domainInfo) (\s :: DescribeDomainResponse
s@DescribeDomainResponse' {} DomainInfo
a -> DescribeDomainResponse
s {$sel:domainInfo:DescribeDomainResponse' :: DomainInfo
domainInfo = DomainInfo
a} :: DescribeDomainResponse)

-- | The domain configuration. Currently, this includes only the domain\'s
-- retention period.
describeDomainResponse_configuration :: Lens.Lens' DescribeDomainResponse DomainConfiguration
describeDomainResponse_configuration :: Lens' DescribeDomainResponse DomainConfiguration
describeDomainResponse_configuration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDomainResponse' {DomainConfiguration
configuration :: DomainConfiguration
$sel:configuration:DescribeDomainResponse' :: DescribeDomainResponse -> DomainConfiguration
configuration} -> DomainConfiguration
configuration) (\s :: DescribeDomainResponse
s@DescribeDomainResponse' {} DomainConfiguration
a -> DescribeDomainResponse
s {$sel:configuration:DescribeDomainResponse' :: DomainConfiguration
configuration = DomainConfiguration
a} :: DescribeDomainResponse)

instance Prelude.NFData DescribeDomainResponse where
  rnf :: DescribeDomainResponse -> ()
rnf DescribeDomainResponse' {Int
DomainConfiguration
DomainInfo
configuration :: DomainConfiguration
domainInfo :: DomainInfo
httpStatus :: Int
$sel:configuration:DescribeDomainResponse' :: DescribeDomainResponse -> DomainConfiguration
$sel:domainInfo:DescribeDomainResponse' :: DescribeDomainResponse -> DomainInfo
$sel:httpStatus:DescribeDomainResponse' :: DescribeDomainResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DomainInfo
domainInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DomainConfiguration
configuration