{-# 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.DescribeRepository
-- 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 @RepositoryDescription@ object that contains detailed
-- information about the requested repository.
module Amazonka.CodeArtifact.DescribeRepository
  ( -- * Creating a Request
    DescribeRepository (..),
    newDescribeRepository,

    -- * Request Lenses
    describeRepository_domainOwner,
    describeRepository_domain,
    describeRepository_repository,

    -- * Destructuring the Response
    DescribeRepositoryResponse (..),
    newDescribeRepositoryResponse,

    -- * Response Lenses
    describeRepositoryResponse_repository,
    describeRepositoryResponse_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:/ 'newDescribeRepository' smart constructor.
data DescribeRepository = DescribeRepository'
  { -- | The 12-digit account number of the Amazon Web Services account that owns
    -- the domain. It does not include dashes or spaces.
    DescribeRepository -> Maybe Text
domainOwner :: Prelude.Maybe Prelude.Text,
    -- | The name of the domain that contains the repository to describe.
    DescribeRepository -> Text
domain :: Prelude.Text,
    -- | A string that specifies the name of the requested repository.
    DescribeRepository -> Text
repository :: Prelude.Text
  }
  deriving (DescribeRepository -> DescribeRepository -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeRepository -> DescribeRepository -> Bool
$c/= :: DescribeRepository -> DescribeRepository -> Bool
== :: DescribeRepository -> DescribeRepository -> Bool
$c== :: DescribeRepository -> DescribeRepository -> Bool
Prelude.Eq, ReadPrec [DescribeRepository]
ReadPrec DescribeRepository
Int -> ReadS DescribeRepository
ReadS [DescribeRepository]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeRepository]
$creadListPrec :: ReadPrec [DescribeRepository]
readPrec :: ReadPrec DescribeRepository
$creadPrec :: ReadPrec DescribeRepository
readList :: ReadS [DescribeRepository]
$creadList :: ReadS [DescribeRepository]
readsPrec :: Int -> ReadS DescribeRepository
$creadsPrec :: Int -> ReadS DescribeRepository
Prelude.Read, Int -> DescribeRepository -> ShowS
[DescribeRepository] -> ShowS
DescribeRepository -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeRepository] -> ShowS
$cshowList :: [DescribeRepository] -> ShowS
show :: DescribeRepository -> String
$cshow :: DescribeRepository -> String
showsPrec :: Int -> DescribeRepository -> ShowS
$cshowsPrec :: Int -> DescribeRepository -> ShowS
Prelude.Show, forall x. Rep DescribeRepository x -> DescribeRepository
forall x. DescribeRepository -> Rep DescribeRepository x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeRepository x -> DescribeRepository
$cfrom :: forall x. DescribeRepository -> Rep DescribeRepository x
Prelude.Generic)

-- |
-- Create a value of 'DescribeRepository' 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', 'describeRepository_domainOwner' - The 12-digit account number of the Amazon Web Services account that owns
-- the domain. It does not include dashes or spaces.
--
-- 'domain', 'describeRepository_domain' - The name of the domain that contains the repository to describe.
--
-- 'repository', 'describeRepository_repository' - A string that specifies the name of the requested repository.
newDescribeRepository ::
  -- | 'domain'
  Prelude.Text ->
  -- | 'repository'
  Prelude.Text ->
  DescribeRepository
newDescribeRepository :: Text -> Text -> DescribeRepository
newDescribeRepository Text
pDomain_ Text
pRepository_ =
  DescribeRepository'
    { $sel:domainOwner:DescribeRepository' :: Maybe Text
domainOwner = forall a. Maybe a
Prelude.Nothing,
      $sel:domain:DescribeRepository' :: Text
domain = Text
pDomain_,
      $sel:repository:DescribeRepository' :: Text
repository = Text
pRepository_
    }

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

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

-- | A string that specifies the name of the requested repository.
describeRepository_repository :: Lens.Lens' DescribeRepository Prelude.Text
describeRepository_repository :: Lens' DescribeRepository Text
describeRepository_repository = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRepository' {Text
repository :: Text
$sel:repository:DescribeRepository' :: DescribeRepository -> Text
repository} -> Text
repository) (\s :: DescribeRepository
s@DescribeRepository' {} Text
a -> DescribeRepository
s {$sel:repository:DescribeRepository' :: Text
repository = Text
a} :: DescribeRepository)

instance Core.AWSRequest DescribeRepository where
  type
    AWSResponse DescribeRepository =
      DescribeRepositoryResponse
  request :: (Service -> Service)
-> DescribeRepository -> Request DescribeRepository
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 DescribeRepository
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeRepository)))
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 RepositoryDescription -> Int -> DescribeRepositoryResponse
DescribeRepositoryResponse'
            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
"repository")
            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 DescribeRepository where
  hashWithSalt :: Int -> DescribeRepository -> Int
hashWithSalt Int
_salt DescribeRepository' {Maybe Text
Text
repository :: Text
domain :: Text
domainOwner :: Maybe Text
$sel:repository:DescribeRepository' :: DescribeRepository -> Text
$sel:domain:DescribeRepository' :: DescribeRepository -> Text
$sel:domainOwner:DescribeRepository' :: DescribeRepository -> 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
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
repository

instance Prelude.NFData DescribeRepository where
  rnf :: DescribeRepository -> ()
rnf DescribeRepository' {Maybe Text
Text
repository :: Text
domain :: Text
domainOwner :: Maybe Text
$sel:repository:DescribeRepository' :: DescribeRepository -> Text
$sel:domain:DescribeRepository' :: DescribeRepository -> Text
$sel:domainOwner:DescribeRepository' :: DescribeRepository -> 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
repository

instance Data.ToHeaders DescribeRepository where
  toHeaders :: DescribeRepository -> 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 DescribeRepository where
  toPath :: DescribeRepository -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v1/repository"

instance Data.ToQuery DescribeRepository where
  toQuery :: DescribeRepository -> QueryString
toQuery DescribeRepository' {Maybe Text
Text
repository :: Text
domain :: Text
domainOwner :: Maybe Text
$sel:repository:DescribeRepository' :: DescribeRepository -> Text
$sel:domain:DescribeRepository' :: DescribeRepository -> Text
$sel:domainOwner:DescribeRepository' :: DescribeRepository -> 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,
        ByteString
"repository" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
repository
      ]

-- | /See:/ 'newDescribeRepositoryResponse' smart constructor.
data DescribeRepositoryResponse = DescribeRepositoryResponse'
  { -- | A @RepositoryDescription@ object that contains the requested repository
    -- information.
    DescribeRepositoryResponse -> Maybe RepositoryDescription
repository :: Prelude.Maybe RepositoryDescription,
    -- | The response's http status code.
    DescribeRepositoryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeRepositoryResponse -> DescribeRepositoryResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeRepositoryResponse -> DescribeRepositoryResponse -> Bool
$c/= :: DescribeRepositoryResponse -> DescribeRepositoryResponse -> Bool
== :: DescribeRepositoryResponse -> DescribeRepositoryResponse -> Bool
$c== :: DescribeRepositoryResponse -> DescribeRepositoryResponse -> Bool
Prelude.Eq, ReadPrec [DescribeRepositoryResponse]
ReadPrec DescribeRepositoryResponse
Int -> ReadS DescribeRepositoryResponse
ReadS [DescribeRepositoryResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeRepositoryResponse]
$creadListPrec :: ReadPrec [DescribeRepositoryResponse]
readPrec :: ReadPrec DescribeRepositoryResponse
$creadPrec :: ReadPrec DescribeRepositoryResponse
readList :: ReadS [DescribeRepositoryResponse]
$creadList :: ReadS [DescribeRepositoryResponse]
readsPrec :: Int -> ReadS DescribeRepositoryResponse
$creadsPrec :: Int -> ReadS DescribeRepositoryResponse
Prelude.Read, Int -> DescribeRepositoryResponse -> ShowS
[DescribeRepositoryResponse] -> ShowS
DescribeRepositoryResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeRepositoryResponse] -> ShowS
$cshowList :: [DescribeRepositoryResponse] -> ShowS
show :: DescribeRepositoryResponse -> String
$cshow :: DescribeRepositoryResponse -> String
showsPrec :: Int -> DescribeRepositoryResponse -> ShowS
$cshowsPrec :: Int -> DescribeRepositoryResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeRepositoryResponse x -> DescribeRepositoryResponse
forall x.
DescribeRepositoryResponse -> Rep DescribeRepositoryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeRepositoryResponse x -> DescribeRepositoryResponse
$cfrom :: forall x.
DescribeRepositoryResponse -> Rep DescribeRepositoryResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeRepositoryResponse' 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:
--
-- 'repository', 'describeRepositoryResponse_repository' - A @RepositoryDescription@ object that contains the requested repository
-- information.
--
-- 'httpStatus', 'describeRepositoryResponse_httpStatus' - The response's http status code.
newDescribeRepositoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeRepositoryResponse
newDescribeRepositoryResponse :: Int -> DescribeRepositoryResponse
newDescribeRepositoryResponse Int
pHttpStatus_ =
  DescribeRepositoryResponse'
    { $sel:repository:DescribeRepositoryResponse' :: Maybe RepositoryDescription
repository =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeRepositoryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A @RepositoryDescription@ object that contains the requested repository
-- information.
describeRepositoryResponse_repository :: Lens.Lens' DescribeRepositoryResponse (Prelude.Maybe RepositoryDescription)
describeRepositoryResponse_repository :: Lens' DescribeRepositoryResponse (Maybe RepositoryDescription)
describeRepositoryResponse_repository = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRepositoryResponse' {Maybe RepositoryDescription
repository :: Maybe RepositoryDescription
$sel:repository:DescribeRepositoryResponse' :: DescribeRepositoryResponse -> Maybe RepositoryDescription
repository} -> Maybe RepositoryDescription
repository) (\s :: DescribeRepositoryResponse
s@DescribeRepositoryResponse' {} Maybe RepositoryDescription
a -> DescribeRepositoryResponse
s {$sel:repository:DescribeRepositoryResponse' :: Maybe RepositoryDescription
repository = Maybe RepositoryDescription
a} :: DescribeRepositoryResponse)

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

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