{-# 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.Backup.DescribeCopyJob
-- 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 metadata associated with creating a copy of a resource.
module Amazonka.Backup.DescribeCopyJob
  ( -- * Creating a Request
    DescribeCopyJob (..),
    newDescribeCopyJob,

    -- * Request Lenses
    describeCopyJob_copyJobId,

    -- * Destructuring the Response
    DescribeCopyJobResponse (..),
    newDescribeCopyJobResponse,

    -- * Response Lenses
    describeCopyJobResponse_copyJob,
    describeCopyJobResponse_httpStatus,
  )
where

import Amazonka.Backup.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:/ 'newDescribeCopyJob' smart constructor.
data DescribeCopyJob = DescribeCopyJob'
  { -- | Uniquely identifies a copy job.
    DescribeCopyJob -> Text
copyJobId :: Prelude.Text
  }
  deriving (DescribeCopyJob -> DescribeCopyJob -> Bool
(DescribeCopyJob -> DescribeCopyJob -> Bool)
-> (DescribeCopyJob -> DescribeCopyJob -> Bool)
-> Eq DescribeCopyJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCopyJob -> DescribeCopyJob -> Bool
$c/= :: DescribeCopyJob -> DescribeCopyJob -> Bool
== :: DescribeCopyJob -> DescribeCopyJob -> Bool
$c== :: DescribeCopyJob -> DescribeCopyJob -> Bool
Prelude.Eq, ReadPrec [DescribeCopyJob]
ReadPrec DescribeCopyJob
Int -> ReadS DescribeCopyJob
ReadS [DescribeCopyJob]
(Int -> ReadS DescribeCopyJob)
-> ReadS [DescribeCopyJob]
-> ReadPrec DescribeCopyJob
-> ReadPrec [DescribeCopyJob]
-> Read DescribeCopyJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCopyJob]
$creadListPrec :: ReadPrec [DescribeCopyJob]
readPrec :: ReadPrec DescribeCopyJob
$creadPrec :: ReadPrec DescribeCopyJob
readList :: ReadS [DescribeCopyJob]
$creadList :: ReadS [DescribeCopyJob]
readsPrec :: Int -> ReadS DescribeCopyJob
$creadsPrec :: Int -> ReadS DescribeCopyJob
Prelude.Read, Int -> DescribeCopyJob -> ShowS
[DescribeCopyJob] -> ShowS
DescribeCopyJob -> String
(Int -> DescribeCopyJob -> ShowS)
-> (DescribeCopyJob -> String)
-> ([DescribeCopyJob] -> ShowS)
-> Show DescribeCopyJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCopyJob] -> ShowS
$cshowList :: [DescribeCopyJob] -> ShowS
show :: DescribeCopyJob -> String
$cshow :: DescribeCopyJob -> String
showsPrec :: Int -> DescribeCopyJob -> ShowS
$cshowsPrec :: Int -> DescribeCopyJob -> ShowS
Prelude.Show, (forall x. DescribeCopyJob -> Rep DescribeCopyJob x)
-> (forall x. Rep DescribeCopyJob x -> DescribeCopyJob)
-> Generic DescribeCopyJob
forall x. Rep DescribeCopyJob x -> DescribeCopyJob
forall x. DescribeCopyJob -> Rep DescribeCopyJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeCopyJob x -> DescribeCopyJob
$cfrom :: forall x. DescribeCopyJob -> Rep DescribeCopyJob x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCopyJob' 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:
--
-- 'copyJobId', 'describeCopyJob_copyJobId' - Uniquely identifies a copy job.
newDescribeCopyJob ::
  -- | 'copyJobId'
  Prelude.Text ->
  DescribeCopyJob
newDescribeCopyJob :: Text -> DescribeCopyJob
newDescribeCopyJob Text
pCopyJobId_ =
  DescribeCopyJob' :: Text -> DescribeCopyJob
DescribeCopyJob' {$sel:copyJobId:DescribeCopyJob' :: Text
copyJobId = Text
pCopyJobId_}

-- | Uniquely identifies a copy job.
describeCopyJob_copyJobId :: Lens.Lens' DescribeCopyJob Prelude.Text
describeCopyJob_copyJobId :: (Text -> f Text) -> DescribeCopyJob -> f DescribeCopyJob
describeCopyJob_copyJobId = (DescribeCopyJob -> Text)
-> (DescribeCopyJob -> Text -> DescribeCopyJob)
-> Lens DescribeCopyJob DescribeCopyJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCopyJob' {Text
copyJobId :: Text
$sel:copyJobId:DescribeCopyJob' :: DescribeCopyJob -> Text
copyJobId} -> Text
copyJobId) (\s :: DescribeCopyJob
s@DescribeCopyJob' {} Text
a -> DescribeCopyJob
s {$sel:copyJobId:DescribeCopyJob' :: Text
copyJobId = Text
a} :: DescribeCopyJob)

instance Core.AWSRequest DescribeCopyJob where
  type
    AWSResponse DescribeCopyJob =
      DescribeCopyJobResponse
  request :: DescribeCopyJob -> Request DescribeCopyJob
request = Service -> DescribeCopyJob -> Request DescribeCopyJob
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeCopyJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeCopyJob)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeCopyJob))
-> Logger
-> Service
-> Proxy DescribeCopyJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeCopyJob)))
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 CopyJob -> Int -> DescribeCopyJobResponse
DescribeCopyJobResponse'
            (Maybe CopyJob -> Int -> DescribeCopyJobResponse)
-> Either String (Maybe CopyJob)
-> Either String (Int -> DescribeCopyJobResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe CopyJob)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"CopyJob")
            Either String (Int -> DescribeCopyJobResponse)
-> Either String Int -> Either String DescribeCopyJobResponse
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 DescribeCopyJob

instance Prelude.NFData DescribeCopyJob

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

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

-- | /See:/ 'newDescribeCopyJobResponse' smart constructor.
data DescribeCopyJobResponse = DescribeCopyJobResponse'
  { -- | Contains detailed information about a copy job.
    DescribeCopyJobResponse -> Maybe CopyJob
copyJob :: Prelude.Maybe CopyJob,
    -- | The response's http status code.
    DescribeCopyJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeCopyJobResponse -> DescribeCopyJobResponse -> Bool
(DescribeCopyJobResponse -> DescribeCopyJobResponse -> Bool)
-> (DescribeCopyJobResponse -> DescribeCopyJobResponse -> Bool)
-> Eq DescribeCopyJobResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCopyJobResponse -> DescribeCopyJobResponse -> Bool
$c/= :: DescribeCopyJobResponse -> DescribeCopyJobResponse -> Bool
== :: DescribeCopyJobResponse -> DescribeCopyJobResponse -> Bool
$c== :: DescribeCopyJobResponse -> DescribeCopyJobResponse -> Bool
Prelude.Eq, ReadPrec [DescribeCopyJobResponse]
ReadPrec DescribeCopyJobResponse
Int -> ReadS DescribeCopyJobResponse
ReadS [DescribeCopyJobResponse]
(Int -> ReadS DescribeCopyJobResponse)
-> ReadS [DescribeCopyJobResponse]
-> ReadPrec DescribeCopyJobResponse
-> ReadPrec [DescribeCopyJobResponse]
-> Read DescribeCopyJobResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCopyJobResponse]
$creadListPrec :: ReadPrec [DescribeCopyJobResponse]
readPrec :: ReadPrec DescribeCopyJobResponse
$creadPrec :: ReadPrec DescribeCopyJobResponse
readList :: ReadS [DescribeCopyJobResponse]
$creadList :: ReadS [DescribeCopyJobResponse]
readsPrec :: Int -> ReadS DescribeCopyJobResponse
$creadsPrec :: Int -> ReadS DescribeCopyJobResponse
Prelude.Read, Int -> DescribeCopyJobResponse -> ShowS
[DescribeCopyJobResponse] -> ShowS
DescribeCopyJobResponse -> String
(Int -> DescribeCopyJobResponse -> ShowS)
-> (DescribeCopyJobResponse -> String)
-> ([DescribeCopyJobResponse] -> ShowS)
-> Show DescribeCopyJobResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCopyJobResponse] -> ShowS
$cshowList :: [DescribeCopyJobResponse] -> ShowS
show :: DescribeCopyJobResponse -> String
$cshow :: DescribeCopyJobResponse -> String
showsPrec :: Int -> DescribeCopyJobResponse -> ShowS
$cshowsPrec :: Int -> DescribeCopyJobResponse -> ShowS
Prelude.Show, (forall x.
 DescribeCopyJobResponse -> Rep DescribeCopyJobResponse x)
-> (forall x.
    Rep DescribeCopyJobResponse x -> DescribeCopyJobResponse)
-> Generic DescribeCopyJobResponse
forall x. Rep DescribeCopyJobResponse x -> DescribeCopyJobResponse
forall x. DescribeCopyJobResponse -> Rep DescribeCopyJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeCopyJobResponse x -> DescribeCopyJobResponse
$cfrom :: forall x. DescribeCopyJobResponse -> Rep DescribeCopyJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCopyJobResponse' 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:
--
-- 'copyJob', 'describeCopyJobResponse_copyJob' - Contains detailed information about a copy job.
--
-- 'httpStatus', 'describeCopyJobResponse_httpStatus' - The response's http status code.
newDescribeCopyJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeCopyJobResponse
newDescribeCopyJobResponse :: Int -> DescribeCopyJobResponse
newDescribeCopyJobResponse Int
pHttpStatus_ =
  DescribeCopyJobResponse' :: Maybe CopyJob -> Int -> DescribeCopyJobResponse
DescribeCopyJobResponse'
    { $sel:copyJob:DescribeCopyJobResponse' :: Maybe CopyJob
copyJob = Maybe CopyJob
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeCopyJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Contains detailed information about a copy job.
describeCopyJobResponse_copyJob :: Lens.Lens' DescribeCopyJobResponse (Prelude.Maybe CopyJob)
describeCopyJobResponse_copyJob :: (Maybe CopyJob -> f (Maybe CopyJob))
-> DescribeCopyJobResponse -> f DescribeCopyJobResponse
describeCopyJobResponse_copyJob = (DescribeCopyJobResponse -> Maybe CopyJob)
-> (DescribeCopyJobResponse
    -> Maybe CopyJob -> DescribeCopyJobResponse)
-> Lens
     DescribeCopyJobResponse
     DescribeCopyJobResponse
     (Maybe CopyJob)
     (Maybe CopyJob)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCopyJobResponse' {Maybe CopyJob
copyJob :: Maybe CopyJob
$sel:copyJob:DescribeCopyJobResponse' :: DescribeCopyJobResponse -> Maybe CopyJob
copyJob} -> Maybe CopyJob
copyJob) (\s :: DescribeCopyJobResponse
s@DescribeCopyJobResponse' {} Maybe CopyJob
a -> DescribeCopyJobResponse
s {$sel:copyJob:DescribeCopyJobResponse' :: Maybe CopyJob
copyJob = Maybe CopyJob
a} :: DescribeCopyJobResponse)

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

instance Prelude.NFData DescribeCopyJobResponse