{-# 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-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 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.Lens as Lens
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
(GetArtifactUrl -> GetArtifactUrl -> Bool)
-> (GetArtifactUrl -> GetArtifactUrl -> Bool) -> Eq GetArtifactUrl
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]
(Int -> ReadS GetArtifactUrl)
-> ReadS [GetArtifactUrl]
-> ReadPrec GetArtifactUrl
-> ReadPrec [GetArtifactUrl]
-> Read 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
(Int -> GetArtifactUrl -> ShowS)
-> (GetArtifactUrl -> String)
-> ([GetArtifactUrl] -> ShowS)
-> Show GetArtifactUrl
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. GetArtifactUrl -> Rep GetArtifactUrl x)
-> (forall x. Rep GetArtifactUrl x -> GetArtifactUrl)
-> Generic GetArtifactUrl
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' :: Text -> GetArtifactUrl
GetArtifactUrl' {$sel:artifactId:GetArtifactUrl' :: Text
artifactId = Text
pArtifactId_}

-- | The unique ID for an artifact.
getArtifactUrl_artifactId :: Lens.Lens' GetArtifactUrl Prelude.Text
getArtifactUrl_artifactId :: (Text -> f Text) -> GetArtifactUrl -> f GetArtifactUrl
getArtifactUrl_artifactId = (GetArtifactUrl -> Text)
-> (GetArtifactUrl -> Text -> GetArtifactUrl)
-> Lens GetArtifactUrl GetArtifactUrl Text Text
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 :: GetArtifactUrl -> Request GetArtifactUrl
request = Service -> GetArtifactUrl -> Request GetArtifactUrl
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetArtifactUrl
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetArtifactUrl)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetArtifactUrl))
-> Logger
-> Service
-> Proxy GetArtifactUrl
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetArtifactUrl)))
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 ->
          Int -> Text -> Text -> GetArtifactUrlResponse
GetArtifactUrlResponse'
            (Int -> Text -> Text -> GetArtifactUrlResponse)
-> Either String Int
-> Either String (Text -> Text -> GetArtifactUrlResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (Text -> Text -> GetArtifactUrlResponse)
-> Either String Text
-> Either String (Text -> GetArtifactUrlResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"artifactId")
            Either String (Text -> GetArtifactUrlResponse)
-> Either String Text -> Either String GetArtifactUrlResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"artifactUrl")
      )

instance Prelude.Hashable GetArtifactUrl

instance Prelude.NFData GetArtifactUrl

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

instance Core.ToQuery GetArtifactUrl where
  toQuery :: GetArtifactUrl -> QueryString
toQuery = QueryString -> GetArtifactUrl -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetArtifactUrlResponse -> GetArtifactUrlResponse -> Bool)
-> (GetArtifactUrlResponse -> GetArtifactUrlResponse -> Bool)
-> Eq GetArtifactUrlResponse
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]
(Int -> ReadS GetArtifactUrlResponse)
-> ReadS [GetArtifactUrlResponse]
-> ReadPrec GetArtifactUrlResponse
-> ReadPrec [GetArtifactUrlResponse]
-> Read 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
(Int -> GetArtifactUrlResponse -> ShowS)
-> (GetArtifactUrlResponse -> String)
-> ([GetArtifactUrlResponse] -> ShowS)
-> Show GetArtifactUrlResponse
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. GetArtifactUrlResponse -> Rep GetArtifactUrlResponse x)
-> (forall x.
    Rep GetArtifactUrlResponse x -> GetArtifactUrlResponse)
-> Generic GetArtifactUrlResponse
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' :: Int -> Text -> Text -> GetArtifactUrlResponse
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 :: (Int -> f Int)
-> GetArtifactUrlResponse -> f GetArtifactUrlResponse
getArtifactUrlResponse_httpStatus = (GetArtifactUrlResponse -> Int)
-> (GetArtifactUrlResponse -> Int -> GetArtifactUrlResponse)
-> Lens GetArtifactUrlResponse GetArtifactUrlResponse Int Int
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 :: (Text -> f Text)
-> GetArtifactUrlResponse -> f GetArtifactUrlResponse
getArtifactUrlResponse_artifactId = (GetArtifactUrlResponse -> Text)
-> (GetArtifactUrlResponse -> Text -> GetArtifactUrlResponse)
-> Lens GetArtifactUrlResponse GetArtifactUrlResponse Text Text
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 :: (Text -> f Text)
-> GetArtifactUrlResponse -> f GetArtifactUrlResponse
getArtifactUrlResponse_artifactUrl = (GetArtifactUrlResponse -> Text)
-> (GetArtifactUrlResponse -> Text -> GetArtifactUrlResponse)
-> Lens GetArtifactUrlResponse GetArtifactUrlResponse Text Text
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