{-# 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-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)
--
-- 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.Lens as Lens
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 AWS 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
(DescribeRepository -> DescribeRepository -> Bool)
-> (DescribeRepository -> DescribeRepository -> Bool)
-> Eq DescribeRepository
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]
(Int -> ReadS DescribeRepository)
-> ReadS [DescribeRepository]
-> ReadPrec DescribeRepository
-> ReadPrec [DescribeRepository]
-> Read 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
(Int -> DescribeRepository -> ShowS)
-> (DescribeRepository -> String)
-> ([DescribeRepository] -> ShowS)
-> Show DescribeRepository
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. DescribeRepository -> Rep DescribeRepository x)
-> (forall x. Rep DescribeRepository x -> DescribeRepository)
-> Generic DescribeRepository
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 AWS 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' :: Maybe Text -> Text -> Text -> DescribeRepository
DescribeRepository'
    { $sel:domainOwner:DescribeRepository' :: Maybe Text
domainOwner = Maybe Text
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 AWS account that owns the domain. It
-- does not include dashes or spaces.
describeRepository_domainOwner :: Lens.Lens' DescribeRepository (Prelude.Maybe Prelude.Text)
describeRepository_domainOwner :: (Maybe Text -> f (Maybe Text))
-> DescribeRepository -> f DescribeRepository
describeRepository_domainOwner = (DescribeRepository -> Maybe Text)
-> (DescribeRepository -> Maybe Text -> DescribeRepository)
-> Lens
     DescribeRepository DescribeRepository (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> DescribeRepository -> f DescribeRepository
describeRepository_domain = (DescribeRepository -> Text)
-> (DescribeRepository -> Text -> DescribeRepository)
-> Lens DescribeRepository DescribeRepository Text Text
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 :: (Text -> f Text) -> DescribeRepository -> f DescribeRepository
describeRepository_repository = (DescribeRepository -> Text)
-> (DescribeRepository -> Text -> DescribeRepository)
-> Lens DescribeRepository DescribeRepository Text Text
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 :: DescribeRepository -> Request DescribeRepository
request = Service -> DescribeRepository -> Request DescribeRepository
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeRepository
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeRepository)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeRepository))
-> Logger
-> Service
-> Proxy DescribeRepository
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeRepository)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe RepositoryDescription -> Int -> DescribeRepositoryResponse
DescribeRepositoryResponse'
            (Maybe RepositoryDescription -> Int -> DescribeRepositoryResponse)
-> Either String (Maybe RepositoryDescription)
-> Either String (Int -> DescribeRepositoryResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe RepositoryDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"repository")
            Either String (Int -> DescribeRepositoryResponse)
-> Either String Int -> Either String DescribeRepositoryResponse
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 DescribeRepository

instance Prelude.NFData DescribeRepository

instance Core.ToHeaders DescribeRepository where
  toHeaders :: DescribeRepository -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeRepository -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"domain-owner" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
domainOwner,
        ByteString
"domain" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
domain,
        ByteString
"repository" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: 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
(DescribeRepositoryResponse -> DescribeRepositoryResponse -> Bool)
-> (DescribeRepositoryResponse
    -> DescribeRepositoryResponse -> Bool)
-> Eq DescribeRepositoryResponse
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]
(Int -> ReadS DescribeRepositoryResponse)
-> ReadS [DescribeRepositoryResponse]
-> ReadPrec DescribeRepositoryResponse
-> ReadPrec [DescribeRepositoryResponse]
-> Read 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
(Int -> DescribeRepositoryResponse -> ShowS)
-> (DescribeRepositoryResponse -> String)
-> ([DescribeRepositoryResponse] -> ShowS)
-> Show DescribeRepositoryResponse
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.
 DescribeRepositoryResponse -> Rep DescribeRepositoryResponse x)
-> (forall x.
    Rep DescribeRepositoryResponse x -> DescribeRepositoryResponse)
-> Generic DescribeRepositoryResponse
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' :: Maybe RepositoryDescription -> Int -> DescribeRepositoryResponse
DescribeRepositoryResponse'
    { $sel:repository:DescribeRepositoryResponse' :: Maybe RepositoryDescription
repository =
        Maybe RepositoryDescription
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 :: (Maybe RepositoryDescription -> f (Maybe RepositoryDescription))
-> DescribeRepositoryResponse -> f DescribeRepositoryResponse
describeRepositoryResponse_repository = (DescribeRepositoryResponse -> Maybe RepositoryDescription)
-> (DescribeRepositoryResponse
    -> Maybe RepositoryDescription -> DescribeRepositoryResponse)
-> Lens
     DescribeRepositoryResponse
     DescribeRepositoryResponse
     (Maybe RepositoryDescription)
     (Maybe RepositoryDescription)
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 :: (Int -> f Int)
-> DescribeRepositoryResponse -> f DescribeRepositoryResponse
describeRepositoryResponse_httpStatus = (DescribeRepositoryResponse -> Int)
-> (DescribeRepositoryResponse
    -> Int -> DescribeRepositoryResponse)
-> Lens
     DescribeRepositoryResponse DescribeRepositoryResponse Int Int
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