{-# 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.GetRepositoryEndpoint
-- 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 the endpoint of a repository for a specific package format. A
-- repository has one endpoint for each package format:
--
-- -   @maven@
--
-- -   @npm@
--
-- -   @nuget@
--
-- -   @pypi@
module Amazonka.CodeArtifact.GetRepositoryEndpoint
  ( -- * Creating a Request
    GetRepositoryEndpoint (..),
    newGetRepositoryEndpoint,

    -- * Request Lenses
    getRepositoryEndpoint_domainOwner,
    getRepositoryEndpoint_domain,
    getRepositoryEndpoint_repository,
    getRepositoryEndpoint_format,

    -- * Destructuring the Response
    GetRepositoryEndpointResponse (..),
    newGetRepositoryEndpointResponse,

    -- * Response Lenses
    getRepositoryEndpointResponse_repositoryEndpoint,
    getRepositoryEndpointResponse_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:/ 'newGetRepositoryEndpoint' smart constructor.
data GetRepositoryEndpoint = GetRepositoryEndpoint'
  { -- | The 12-digit account number of the Amazon Web Services account that owns
    -- the domain that contains the repository. It does not include dashes or
    -- spaces.
    GetRepositoryEndpoint -> Maybe Text
domainOwner :: Prelude.Maybe Prelude.Text,
    -- | The name of the domain that contains the repository.
    GetRepositoryEndpoint -> Text
domain :: Prelude.Text,
    -- | The name of the repository.
    GetRepositoryEndpoint -> Text
repository :: Prelude.Text,
    -- | Returns which endpoint of a repository to return. A repository has one
    -- endpoint for each package format.
    GetRepositoryEndpoint -> PackageFormat
format :: PackageFormat
  }
  deriving (GetRepositoryEndpoint -> GetRepositoryEndpoint -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRepositoryEndpoint -> GetRepositoryEndpoint -> Bool
$c/= :: GetRepositoryEndpoint -> GetRepositoryEndpoint -> Bool
== :: GetRepositoryEndpoint -> GetRepositoryEndpoint -> Bool
$c== :: GetRepositoryEndpoint -> GetRepositoryEndpoint -> Bool
Prelude.Eq, ReadPrec [GetRepositoryEndpoint]
ReadPrec GetRepositoryEndpoint
Int -> ReadS GetRepositoryEndpoint
ReadS [GetRepositoryEndpoint]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRepositoryEndpoint]
$creadListPrec :: ReadPrec [GetRepositoryEndpoint]
readPrec :: ReadPrec GetRepositoryEndpoint
$creadPrec :: ReadPrec GetRepositoryEndpoint
readList :: ReadS [GetRepositoryEndpoint]
$creadList :: ReadS [GetRepositoryEndpoint]
readsPrec :: Int -> ReadS GetRepositoryEndpoint
$creadsPrec :: Int -> ReadS GetRepositoryEndpoint
Prelude.Read, Int -> GetRepositoryEndpoint -> ShowS
[GetRepositoryEndpoint] -> ShowS
GetRepositoryEndpoint -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRepositoryEndpoint] -> ShowS
$cshowList :: [GetRepositoryEndpoint] -> ShowS
show :: GetRepositoryEndpoint -> String
$cshow :: GetRepositoryEndpoint -> String
showsPrec :: Int -> GetRepositoryEndpoint -> ShowS
$cshowsPrec :: Int -> GetRepositoryEndpoint -> ShowS
Prelude.Show, forall x. Rep GetRepositoryEndpoint x -> GetRepositoryEndpoint
forall x. GetRepositoryEndpoint -> Rep GetRepositoryEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRepositoryEndpoint x -> GetRepositoryEndpoint
$cfrom :: forall x. GetRepositoryEndpoint -> Rep GetRepositoryEndpoint x
Prelude.Generic)

-- |
-- Create a value of 'GetRepositoryEndpoint' 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', 'getRepositoryEndpoint_domainOwner' - The 12-digit account number of the Amazon Web Services account that owns
-- the domain that contains the repository. It does not include dashes or
-- spaces.
--
-- 'domain', 'getRepositoryEndpoint_domain' - The name of the domain that contains the repository.
--
-- 'repository', 'getRepositoryEndpoint_repository' - The name of the repository.
--
-- 'format', 'getRepositoryEndpoint_format' - Returns which endpoint of a repository to return. A repository has one
-- endpoint for each package format.
newGetRepositoryEndpoint ::
  -- | 'domain'
  Prelude.Text ->
  -- | 'repository'
  Prelude.Text ->
  -- | 'format'
  PackageFormat ->
  GetRepositoryEndpoint
newGetRepositoryEndpoint :: Text -> Text -> PackageFormat -> GetRepositoryEndpoint
newGetRepositoryEndpoint
  Text
pDomain_
  Text
pRepository_
  PackageFormat
pFormat_ =
    GetRepositoryEndpoint'
      { $sel:domainOwner:GetRepositoryEndpoint' :: Maybe Text
domainOwner =
          forall a. Maybe a
Prelude.Nothing,
        $sel:domain:GetRepositoryEndpoint' :: Text
domain = Text
pDomain_,
        $sel:repository:GetRepositoryEndpoint' :: Text
repository = Text
pRepository_,
        $sel:format:GetRepositoryEndpoint' :: PackageFormat
format = PackageFormat
pFormat_
      }

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

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

-- | The name of the repository.
getRepositoryEndpoint_repository :: Lens.Lens' GetRepositoryEndpoint Prelude.Text
getRepositoryEndpoint_repository :: Lens' GetRepositoryEndpoint Text
getRepositoryEndpoint_repository = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRepositoryEndpoint' {Text
repository :: Text
$sel:repository:GetRepositoryEndpoint' :: GetRepositoryEndpoint -> Text
repository} -> Text
repository) (\s :: GetRepositoryEndpoint
s@GetRepositoryEndpoint' {} Text
a -> GetRepositoryEndpoint
s {$sel:repository:GetRepositoryEndpoint' :: Text
repository = Text
a} :: GetRepositoryEndpoint)

-- | Returns which endpoint of a repository to return. A repository has one
-- endpoint for each package format.
getRepositoryEndpoint_format :: Lens.Lens' GetRepositoryEndpoint PackageFormat
getRepositoryEndpoint_format :: Lens' GetRepositoryEndpoint PackageFormat
getRepositoryEndpoint_format = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRepositoryEndpoint' {PackageFormat
format :: PackageFormat
$sel:format:GetRepositoryEndpoint' :: GetRepositoryEndpoint -> PackageFormat
format} -> PackageFormat
format) (\s :: GetRepositoryEndpoint
s@GetRepositoryEndpoint' {} PackageFormat
a -> GetRepositoryEndpoint
s {$sel:format:GetRepositoryEndpoint' :: PackageFormat
format = PackageFormat
a} :: GetRepositoryEndpoint)

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

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

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

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

-- | /See:/ 'newGetRepositoryEndpointResponse' smart constructor.
data GetRepositoryEndpointResponse = GetRepositoryEndpointResponse'
  { -- | A string that specifies the URL of the returned endpoint.
    GetRepositoryEndpointResponse -> Maybe Text
repositoryEndpoint :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetRepositoryEndpointResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetRepositoryEndpointResponse
-> GetRepositoryEndpointResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRepositoryEndpointResponse
-> GetRepositoryEndpointResponse -> Bool
$c/= :: GetRepositoryEndpointResponse
-> GetRepositoryEndpointResponse -> Bool
== :: GetRepositoryEndpointResponse
-> GetRepositoryEndpointResponse -> Bool
$c== :: GetRepositoryEndpointResponse
-> GetRepositoryEndpointResponse -> Bool
Prelude.Eq, ReadPrec [GetRepositoryEndpointResponse]
ReadPrec GetRepositoryEndpointResponse
Int -> ReadS GetRepositoryEndpointResponse
ReadS [GetRepositoryEndpointResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRepositoryEndpointResponse]
$creadListPrec :: ReadPrec [GetRepositoryEndpointResponse]
readPrec :: ReadPrec GetRepositoryEndpointResponse
$creadPrec :: ReadPrec GetRepositoryEndpointResponse
readList :: ReadS [GetRepositoryEndpointResponse]
$creadList :: ReadS [GetRepositoryEndpointResponse]
readsPrec :: Int -> ReadS GetRepositoryEndpointResponse
$creadsPrec :: Int -> ReadS GetRepositoryEndpointResponse
Prelude.Read, Int -> GetRepositoryEndpointResponse -> ShowS
[GetRepositoryEndpointResponse] -> ShowS
GetRepositoryEndpointResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRepositoryEndpointResponse] -> ShowS
$cshowList :: [GetRepositoryEndpointResponse] -> ShowS
show :: GetRepositoryEndpointResponse -> String
$cshow :: GetRepositoryEndpointResponse -> String
showsPrec :: Int -> GetRepositoryEndpointResponse -> ShowS
$cshowsPrec :: Int -> GetRepositoryEndpointResponse -> ShowS
Prelude.Show, forall x.
Rep GetRepositoryEndpointResponse x
-> GetRepositoryEndpointResponse
forall x.
GetRepositoryEndpointResponse
-> Rep GetRepositoryEndpointResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetRepositoryEndpointResponse x
-> GetRepositoryEndpointResponse
$cfrom :: forall x.
GetRepositoryEndpointResponse
-> Rep GetRepositoryEndpointResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetRepositoryEndpointResponse' 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:
--
-- 'repositoryEndpoint', 'getRepositoryEndpointResponse_repositoryEndpoint' - A string that specifies the URL of the returned endpoint.
--
-- 'httpStatus', 'getRepositoryEndpointResponse_httpStatus' - The response's http status code.
newGetRepositoryEndpointResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetRepositoryEndpointResponse
newGetRepositoryEndpointResponse :: Int -> GetRepositoryEndpointResponse
newGetRepositoryEndpointResponse Int
pHttpStatus_ =
  GetRepositoryEndpointResponse'
    { $sel:repositoryEndpoint:GetRepositoryEndpointResponse' :: Maybe Text
repositoryEndpoint =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetRepositoryEndpointResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A string that specifies the URL of the returned endpoint.
getRepositoryEndpointResponse_repositoryEndpoint :: Lens.Lens' GetRepositoryEndpointResponse (Prelude.Maybe Prelude.Text)
getRepositoryEndpointResponse_repositoryEndpoint :: Lens' GetRepositoryEndpointResponse (Maybe Text)
getRepositoryEndpointResponse_repositoryEndpoint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRepositoryEndpointResponse' {Maybe Text
repositoryEndpoint :: Maybe Text
$sel:repositoryEndpoint:GetRepositoryEndpointResponse' :: GetRepositoryEndpointResponse -> Maybe Text
repositoryEndpoint} -> Maybe Text
repositoryEndpoint) (\s :: GetRepositoryEndpointResponse
s@GetRepositoryEndpointResponse' {} Maybe Text
a -> GetRepositoryEndpointResponse
s {$sel:repositoryEndpoint:GetRepositoryEndpointResponse' :: Maybe Text
repositoryEndpoint = Maybe Text
a} :: GetRepositoryEndpointResponse)

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

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