{-# 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.CodeArtifact.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 a
-- <https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_DomainDescription.html DomainDescription>
-- object that contains information about the requested domain.
module Amazonka.CodeArtifact.DescribeDomain
  ( -- * Creating a Request
    DescribeDomain (..),
    newDescribeDomain,

    -- * Request Lenses
    describeDomain_domainOwner,
    describeDomain_domain,

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

    -- * Response Lenses
    describeDomainResponse_domain,
    describeDomainResponse_httpStatus,
  )
where

import Amazonka.CodeArtifact.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:/ 'newDescribeDomain' smart constructor.
data DescribeDomain = DescribeDomain'
  { -- | The 12-digit account number of the Amazon Web Services account that owns
    -- the domain. It does not include dashes or spaces.
    DescribeDomain -> Maybe Text
domainOwner :: Prelude.Maybe Prelude.Text,
    -- | A string that specifies the name of the requested domain.
    DescribeDomain -> Text
domain :: 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:
--
-- 'domainOwner', 'describeDomain_domainOwner' - The 12-digit account number of the Amazon Web Services account that owns
-- the domain. It does not include dashes or spaces.
--
-- 'domain', 'describeDomain_domain' - A string that specifies the name of the requested domain.
newDescribeDomain ::
  -- | 'domain'
  Prelude.Text ->
  DescribeDomain
newDescribeDomain :: Text -> DescribeDomain
newDescribeDomain Text
pDomain_ =
  DescribeDomain'
    { $sel:domainOwner:DescribeDomain' :: Maybe Text
domainOwner = forall a. Maybe a
Prelude.Nothing,
      $sel:domain:DescribeDomain' :: Text
domain = Text
pDomain_
    }

-- | The 12-digit account number of the Amazon Web Services account that owns
-- the domain. It does not include dashes or spaces.
describeDomain_domainOwner :: Lens.Lens' DescribeDomain (Prelude.Maybe Prelude.Text)
describeDomain_domainOwner :: Lens' DescribeDomain (Maybe Text)
describeDomain_domainOwner = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDomain' {Maybe Text
domainOwner :: Maybe Text
$sel:domainOwner:DescribeDomain' :: DescribeDomain -> Maybe Text
domainOwner} -> Maybe Text
domainOwner) (\s :: DescribeDomain
s@DescribeDomain' {} Maybe Text
a -> DescribeDomain
s {$sel:domainOwner:DescribeDomain' :: Maybe Text
domainOwner = Maybe Text
a} :: DescribeDomain)

-- | A string that specifies the name of the requested domain.
describeDomain_domain :: Lens.Lens' DescribeDomain Prelude.Text
describeDomain_domain :: Lens' DescribeDomain Text
describeDomain_domain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDomain' {Text
domain :: Text
$sel:domain:DescribeDomain' :: DescribeDomain -> Text
domain} -> Text
domain) (\s :: DescribeDomain
s@DescribeDomain' {} Text
a -> DescribeDomain
s {$sel:domain:DescribeDomain' :: Text
domain = 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 => Service -> a -> Request a
Request.get (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 ->
          Maybe DomainDescription -> Int -> DescribeDomainResponse
DescribeDomainResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"domain")
            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 DescribeDomain where
  hashWithSalt :: Int -> DescribeDomain -> Int
hashWithSalt Int
_salt DescribeDomain' {Maybe Text
Text
domain :: Text
domainOwner :: Maybe Text
$sel:domain:DescribeDomain' :: DescribeDomain -> Text
$sel:domainOwner:DescribeDomain' :: DescribeDomain -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
domainOwner
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domain

instance Prelude.NFData DescribeDomain where
  rnf :: DescribeDomain -> ()
rnf DescribeDomain' {Maybe Text
Text
domain :: Text
domainOwner :: Maybe Text
$sel:domain:DescribeDomain' :: DescribeDomain -> Text
$sel:domainOwner:DescribeDomain' :: DescribeDomain -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
domainOwner
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
domain

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
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Data.ToQuery DescribeDomain where
  toQuery :: DescribeDomain -> QueryString
toQuery DescribeDomain' {Maybe Text
Text
domain :: Text
domainOwner :: Maybe Text
$sel:domain:DescribeDomain' :: DescribeDomain -> Text
$sel:domainOwner:DescribeDomain' :: DescribeDomain -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"domain-owner" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
domainOwner,
        ByteString
"domain" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
domain
      ]

-- | /See:/ 'newDescribeDomainResponse' smart constructor.
data DescribeDomainResponse = DescribeDomainResponse'
  { DescribeDomainResponse -> Maybe DomainDescription
domain :: Prelude.Maybe DomainDescription,
    -- | The response's http status code.
    DescribeDomainResponse -> Int
httpStatus :: Prelude.Int
  }
  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:
--
-- 'domain', 'describeDomainResponse_domain' - Undocumented member.
--
-- 'httpStatus', 'describeDomainResponse_httpStatus' - The response's http status code.
newDescribeDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeDomainResponse
newDescribeDomainResponse :: Int -> DescribeDomainResponse
newDescribeDomainResponse Int
pHttpStatus_ =
  DescribeDomainResponse'
    { $sel:domain:DescribeDomainResponse' :: Maybe DomainDescription
domain = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeDomainResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
describeDomainResponse_domain :: Lens.Lens' DescribeDomainResponse (Prelude.Maybe DomainDescription)
describeDomainResponse_domain :: Lens' DescribeDomainResponse (Maybe DomainDescription)
describeDomainResponse_domain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDomainResponse' {Maybe DomainDescription
domain :: Maybe DomainDescription
$sel:domain:DescribeDomainResponse' :: DescribeDomainResponse -> Maybe DomainDescription
domain} -> Maybe DomainDescription
domain) (\s :: DescribeDomainResponse
s@DescribeDomainResponse' {} Maybe DomainDescription
a -> DescribeDomainResponse
s {$sel:domain:DescribeDomainResponse' :: Maybe DomainDescription
domain = Maybe DomainDescription
a} :: DescribeDomainResponse)

-- | 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)

instance Prelude.NFData DescribeDomainResponse where
  rnf :: DescribeDomainResponse -> ()
rnf DescribeDomainResponse' {Int
Maybe DomainDescription
httpStatus :: Int
domain :: Maybe DomainDescription
$sel:httpStatus:DescribeDomainResponse' :: DescribeDomainResponse -> Int
$sel:domain:DescribeDomainResponse' :: DescribeDomainResponse -> Maybe DomainDescription
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DomainDescription
domain
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus