{-# 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.Amplify.GetArtifactUrl
-- 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 artifact info that corresponds to an artifact id.
module Amazonka.Amplify.GetArtifactUrl
  ( -- * Creating a Request
    GetArtifactUrl (..),
    newGetArtifactUrl,

    -- * Request Lenses
    getArtifactUrl_artifactId,

    -- * Destructuring the Response
    GetArtifactUrlResponse (..),
    newGetArtifactUrlResponse,

    -- * Response Lenses
    getArtifactUrlResponse_httpStatus,
    getArtifactUrlResponse_artifactId,
    getArtifactUrlResponse_artifactUrl,
  )
where

import Amazonka.Amplify.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

-- | Returns the request structure for the get artifact request.
--
-- /See:/ 'newGetArtifactUrl' smart constructor.
data GetArtifactUrl = GetArtifactUrl'
  { -- | The unique ID for an artifact.
    GetArtifactUrl -> Text
artifactId :: Prelude.Text
  }
  deriving (GetArtifactUrl -> GetArtifactUrl -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetArtifactUrl -> GetArtifactUrl -> Bool
$c/= :: GetArtifactUrl -> GetArtifactUrl -> Bool
== :: GetArtifactUrl -> GetArtifactUrl -> Bool
$c== :: GetArtifactUrl -> GetArtifactUrl -> Bool
Prelude.Eq, ReadPrec [GetArtifactUrl]
ReadPrec GetArtifactUrl
Int -> ReadS GetArtifactUrl
ReadS [GetArtifactUrl]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetArtifactUrl]
$creadListPrec :: ReadPrec [GetArtifactUrl]
readPrec :: ReadPrec GetArtifactUrl
$creadPrec :: ReadPrec GetArtifactUrl
readList :: ReadS [GetArtifactUrl]
$creadList :: ReadS [GetArtifactUrl]
readsPrec :: Int -> ReadS GetArtifactUrl
$creadsPrec :: Int -> ReadS GetArtifactUrl
Prelude.Read, Int -> GetArtifactUrl -> ShowS
[GetArtifactUrl] -> ShowS
GetArtifactUrl -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetArtifactUrl] -> ShowS
$cshowList :: [GetArtifactUrl] -> ShowS
show :: GetArtifactUrl -> String
$cshow :: GetArtifactUrl -> String
showsPrec :: Int -> GetArtifactUrl -> ShowS
$cshowsPrec :: Int -> GetArtifactUrl -> ShowS
Prelude.Show, forall x. Rep GetArtifactUrl x -> GetArtifactUrl
forall x. GetArtifactUrl -> Rep GetArtifactUrl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetArtifactUrl x -> GetArtifactUrl
$cfrom :: forall x. GetArtifactUrl -> Rep GetArtifactUrl x
Prelude.Generic)

-- |
-- Create a value of 'GetArtifactUrl' 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:
--
-- 'artifactId', 'getArtifactUrl_artifactId' - The unique ID for an artifact.
newGetArtifactUrl ::
  -- | 'artifactId'
  Prelude.Text ->
  GetArtifactUrl
newGetArtifactUrl :: Text -> GetArtifactUrl
newGetArtifactUrl Text
pArtifactId_ =
  GetArtifactUrl' {$sel:artifactId:GetArtifactUrl' :: Text
artifactId = Text
pArtifactId_}

-- | The unique ID for an artifact.
getArtifactUrl_artifactId :: Lens.Lens' GetArtifactUrl Prelude.Text
getArtifactUrl_artifactId :: Lens' GetArtifactUrl Text
getArtifactUrl_artifactId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetArtifactUrl' {Text
artifactId :: Text
$sel:artifactId:GetArtifactUrl' :: GetArtifactUrl -> Text
artifactId} -> Text
artifactId) (\s :: GetArtifactUrl
s@GetArtifactUrl' {} Text
a -> GetArtifactUrl
s {$sel:artifactId:GetArtifactUrl' :: Text
artifactId = Text
a} :: GetArtifactUrl)

instance Core.AWSRequest GetArtifactUrl where
  type
    AWSResponse GetArtifactUrl =
      GetArtifactUrlResponse
  request :: (Service -> Service) -> GetArtifactUrl -> Request GetArtifactUrl
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 GetArtifactUrl
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetArtifactUrl)))
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 -> Text -> Text -> GetArtifactUrlResponse
GetArtifactUrlResponse'
            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
"artifactId")
            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
"artifactUrl")
      )

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

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

instance Data.ToHeaders GetArtifactUrl where
  toHeaders :: GetArtifactUrl -> 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 GetArtifactUrl where
  toPath :: GetArtifactUrl -> ByteString
toPath GetArtifactUrl' {Text
artifactId :: Text
$sel:artifactId:GetArtifactUrl' :: GetArtifactUrl -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/artifacts/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
artifactId]

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

-- | Returns the result structure for the get artifact request.
--
-- /See:/ 'newGetArtifactUrlResponse' smart constructor.
data GetArtifactUrlResponse = GetArtifactUrlResponse'
  { -- | The response's http status code.
    GetArtifactUrlResponse -> Int
httpStatus :: Prelude.Int,
    -- | The unique ID for an artifact.
    GetArtifactUrlResponse -> Text
artifactId :: Prelude.Text,
    -- | The presigned URL for the artifact.
    GetArtifactUrlResponse -> Text
artifactUrl :: Prelude.Text
  }
  deriving (GetArtifactUrlResponse -> GetArtifactUrlResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetArtifactUrlResponse -> GetArtifactUrlResponse -> Bool
$c/= :: GetArtifactUrlResponse -> GetArtifactUrlResponse -> Bool
== :: GetArtifactUrlResponse -> GetArtifactUrlResponse -> Bool
$c== :: GetArtifactUrlResponse -> GetArtifactUrlResponse -> Bool
Prelude.Eq, ReadPrec [GetArtifactUrlResponse]
ReadPrec GetArtifactUrlResponse
Int -> ReadS GetArtifactUrlResponse
ReadS [GetArtifactUrlResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetArtifactUrlResponse]
$creadListPrec :: ReadPrec [GetArtifactUrlResponse]
readPrec :: ReadPrec GetArtifactUrlResponse
$creadPrec :: ReadPrec GetArtifactUrlResponse
readList :: ReadS [GetArtifactUrlResponse]
$creadList :: ReadS [GetArtifactUrlResponse]
readsPrec :: Int -> ReadS GetArtifactUrlResponse
$creadsPrec :: Int -> ReadS GetArtifactUrlResponse
Prelude.Read, Int -> GetArtifactUrlResponse -> ShowS
[GetArtifactUrlResponse] -> ShowS
GetArtifactUrlResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetArtifactUrlResponse] -> ShowS
$cshowList :: [GetArtifactUrlResponse] -> ShowS
show :: GetArtifactUrlResponse -> String
$cshow :: GetArtifactUrlResponse -> String
showsPrec :: Int -> GetArtifactUrlResponse -> ShowS
$cshowsPrec :: Int -> GetArtifactUrlResponse -> ShowS
Prelude.Show, forall x. Rep GetArtifactUrlResponse x -> GetArtifactUrlResponse
forall x. GetArtifactUrlResponse -> Rep GetArtifactUrlResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetArtifactUrlResponse x -> GetArtifactUrlResponse
$cfrom :: forall x. GetArtifactUrlResponse -> Rep GetArtifactUrlResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetArtifactUrlResponse' 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', 'getArtifactUrlResponse_httpStatus' - The response's http status code.
--
-- 'artifactId', 'getArtifactUrlResponse_artifactId' - The unique ID for an artifact.
--
-- 'artifactUrl', 'getArtifactUrlResponse_artifactUrl' - The presigned URL for the artifact.
newGetArtifactUrlResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'artifactId'
  Prelude.Text ->
  -- | 'artifactUrl'
  Prelude.Text ->
  GetArtifactUrlResponse
newGetArtifactUrlResponse :: Int -> Text -> Text -> GetArtifactUrlResponse
newGetArtifactUrlResponse
  Int
pHttpStatus_
  Text
pArtifactId_
  Text
pArtifactUrl_ =
    GetArtifactUrlResponse'
      { $sel:httpStatus:GetArtifactUrlResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:artifactId:GetArtifactUrlResponse' :: Text
artifactId = Text
pArtifactId_,
        $sel:artifactUrl:GetArtifactUrlResponse' :: Text
artifactUrl = Text
pArtifactUrl_
      }

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

-- | The unique ID for an artifact.
getArtifactUrlResponse_artifactId :: Lens.Lens' GetArtifactUrlResponse Prelude.Text
getArtifactUrlResponse_artifactId :: Lens' GetArtifactUrlResponse Text
getArtifactUrlResponse_artifactId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetArtifactUrlResponse' {Text
artifactId :: Text
$sel:artifactId:GetArtifactUrlResponse' :: GetArtifactUrlResponse -> Text
artifactId} -> Text
artifactId) (\s :: GetArtifactUrlResponse
s@GetArtifactUrlResponse' {} Text
a -> GetArtifactUrlResponse
s {$sel:artifactId:GetArtifactUrlResponse' :: Text
artifactId = Text
a} :: GetArtifactUrlResponse)

-- | The presigned URL for the artifact.
getArtifactUrlResponse_artifactUrl :: Lens.Lens' GetArtifactUrlResponse Prelude.Text
getArtifactUrlResponse_artifactUrl :: Lens' GetArtifactUrlResponse Text
getArtifactUrlResponse_artifactUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetArtifactUrlResponse' {Text
artifactUrl :: Text
$sel:artifactUrl:GetArtifactUrlResponse' :: GetArtifactUrlResponse -> Text
artifactUrl} -> Text
artifactUrl) (\s :: GetArtifactUrlResponse
s@GetArtifactUrlResponse' {} Text
a -> GetArtifactUrlResponse
s {$sel:artifactUrl:GetArtifactUrlResponse' :: Text
artifactUrl = Text
a} :: GetArtifactUrlResponse)

instance Prelude.NFData GetArtifactUrlResponse where
  rnf :: GetArtifactUrlResponse -> ()
rnf GetArtifactUrlResponse' {Int
Text
artifactUrl :: Text
artifactId :: Text
httpStatus :: Int
$sel:artifactUrl:GetArtifactUrlResponse' :: GetArtifactUrlResponse -> Text
$sel:artifactId:GetArtifactUrlResponse' :: GetArtifactUrlResponse -> Text
$sel:httpStatus:GetArtifactUrlResponse' :: GetArtifactUrlResponse -> 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 Text
artifactId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
artifactUrl