{-# 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.Snowball.GetSoftwareUpdates
-- 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 an Amazon S3 presigned URL for an update file associated with a
-- specified @JobId@.
module Amazonka.Snowball.GetSoftwareUpdates
  ( -- * Creating a Request
    GetSoftwareUpdates (..),
    newGetSoftwareUpdates,

    -- * Request Lenses
    getSoftwareUpdates_jobId,

    -- * Destructuring the Response
    GetSoftwareUpdatesResponse (..),
    newGetSoftwareUpdatesResponse,

    -- * Response Lenses
    getSoftwareUpdatesResponse_updatesURI,
    getSoftwareUpdatesResponse_httpStatus,
  )
where

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
import Amazonka.Snowball.Types

-- | /See:/ 'newGetSoftwareUpdates' smart constructor.
data GetSoftwareUpdates = GetSoftwareUpdates'
  { -- | The ID for a job that you want to get the software update file for, for
    -- example @JID123e4567-e89b-12d3-a456-426655440000@.
    GetSoftwareUpdates -> Text
jobId :: Prelude.Text
  }
  deriving (GetSoftwareUpdates -> GetSoftwareUpdates -> Bool
(GetSoftwareUpdates -> GetSoftwareUpdates -> Bool)
-> (GetSoftwareUpdates -> GetSoftwareUpdates -> Bool)
-> Eq GetSoftwareUpdates
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSoftwareUpdates -> GetSoftwareUpdates -> Bool
$c/= :: GetSoftwareUpdates -> GetSoftwareUpdates -> Bool
== :: GetSoftwareUpdates -> GetSoftwareUpdates -> Bool
$c== :: GetSoftwareUpdates -> GetSoftwareUpdates -> Bool
Prelude.Eq, ReadPrec [GetSoftwareUpdates]
ReadPrec GetSoftwareUpdates
Int -> ReadS GetSoftwareUpdates
ReadS [GetSoftwareUpdates]
(Int -> ReadS GetSoftwareUpdates)
-> ReadS [GetSoftwareUpdates]
-> ReadPrec GetSoftwareUpdates
-> ReadPrec [GetSoftwareUpdates]
-> Read GetSoftwareUpdates
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSoftwareUpdates]
$creadListPrec :: ReadPrec [GetSoftwareUpdates]
readPrec :: ReadPrec GetSoftwareUpdates
$creadPrec :: ReadPrec GetSoftwareUpdates
readList :: ReadS [GetSoftwareUpdates]
$creadList :: ReadS [GetSoftwareUpdates]
readsPrec :: Int -> ReadS GetSoftwareUpdates
$creadsPrec :: Int -> ReadS GetSoftwareUpdates
Prelude.Read, Int -> GetSoftwareUpdates -> ShowS
[GetSoftwareUpdates] -> ShowS
GetSoftwareUpdates -> String
(Int -> GetSoftwareUpdates -> ShowS)
-> (GetSoftwareUpdates -> String)
-> ([GetSoftwareUpdates] -> ShowS)
-> Show GetSoftwareUpdates
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSoftwareUpdates] -> ShowS
$cshowList :: [GetSoftwareUpdates] -> ShowS
show :: GetSoftwareUpdates -> String
$cshow :: GetSoftwareUpdates -> String
showsPrec :: Int -> GetSoftwareUpdates -> ShowS
$cshowsPrec :: Int -> GetSoftwareUpdates -> ShowS
Prelude.Show, (forall x. GetSoftwareUpdates -> Rep GetSoftwareUpdates x)
-> (forall x. Rep GetSoftwareUpdates x -> GetSoftwareUpdates)
-> Generic GetSoftwareUpdates
forall x. Rep GetSoftwareUpdates x -> GetSoftwareUpdates
forall x. GetSoftwareUpdates -> Rep GetSoftwareUpdates x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSoftwareUpdates x -> GetSoftwareUpdates
$cfrom :: forall x. GetSoftwareUpdates -> Rep GetSoftwareUpdates x
Prelude.Generic)

-- |
-- Create a value of 'GetSoftwareUpdates' 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:
--
-- 'jobId', 'getSoftwareUpdates_jobId' - The ID for a job that you want to get the software update file for, for
-- example @JID123e4567-e89b-12d3-a456-426655440000@.
newGetSoftwareUpdates ::
  -- | 'jobId'
  Prelude.Text ->
  GetSoftwareUpdates
newGetSoftwareUpdates :: Text -> GetSoftwareUpdates
newGetSoftwareUpdates Text
pJobId_ =
  GetSoftwareUpdates' :: Text -> GetSoftwareUpdates
GetSoftwareUpdates' {$sel:jobId:GetSoftwareUpdates' :: Text
jobId = Text
pJobId_}

-- | The ID for a job that you want to get the software update file for, for
-- example @JID123e4567-e89b-12d3-a456-426655440000@.
getSoftwareUpdates_jobId :: Lens.Lens' GetSoftwareUpdates Prelude.Text
getSoftwareUpdates_jobId :: (Text -> f Text) -> GetSoftwareUpdates -> f GetSoftwareUpdates
getSoftwareUpdates_jobId = (GetSoftwareUpdates -> Text)
-> (GetSoftwareUpdates -> Text -> GetSoftwareUpdates)
-> Lens GetSoftwareUpdates GetSoftwareUpdates Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSoftwareUpdates' {Text
jobId :: Text
$sel:jobId:GetSoftwareUpdates' :: GetSoftwareUpdates -> Text
jobId} -> Text
jobId) (\s :: GetSoftwareUpdates
s@GetSoftwareUpdates' {} Text
a -> GetSoftwareUpdates
s {$sel:jobId:GetSoftwareUpdates' :: Text
jobId = Text
a} :: GetSoftwareUpdates)

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

instance Prelude.NFData GetSoftwareUpdates

instance Core.ToHeaders GetSoftwareUpdates where
  toHeaders :: GetSoftwareUpdates -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetSoftwareUpdates -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSIESnowballJobManagementService.GetSoftwareUpdates" ::
                          Prelude.ByteString
                      ),
            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.ToJSON GetSoftwareUpdates where
  toJSON :: GetSoftwareUpdates -> Value
toJSON GetSoftwareUpdates' {Text
jobId :: Text
$sel:jobId:GetSoftwareUpdates' :: GetSoftwareUpdates -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"JobId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
jobId)]
      )

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

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

-- | /See:/ 'newGetSoftwareUpdatesResponse' smart constructor.
data GetSoftwareUpdatesResponse = GetSoftwareUpdatesResponse'
  { -- | The Amazon S3 presigned URL for the update file associated with the
    -- specified @JobId@ value. The software update will be available for 2
    -- days after this request is made. To access an update after the 2 days
    -- have passed, you\'ll have to make another call to @GetSoftwareUpdates@.
    GetSoftwareUpdatesResponse -> Maybe Text
updatesURI :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetSoftwareUpdatesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetSoftwareUpdatesResponse -> GetSoftwareUpdatesResponse -> Bool
(GetSoftwareUpdatesResponse -> GetSoftwareUpdatesResponse -> Bool)
-> (GetSoftwareUpdatesResponse
    -> GetSoftwareUpdatesResponse -> Bool)
-> Eq GetSoftwareUpdatesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSoftwareUpdatesResponse -> GetSoftwareUpdatesResponse -> Bool
$c/= :: GetSoftwareUpdatesResponse -> GetSoftwareUpdatesResponse -> Bool
== :: GetSoftwareUpdatesResponse -> GetSoftwareUpdatesResponse -> Bool
$c== :: GetSoftwareUpdatesResponse -> GetSoftwareUpdatesResponse -> Bool
Prelude.Eq, ReadPrec [GetSoftwareUpdatesResponse]
ReadPrec GetSoftwareUpdatesResponse
Int -> ReadS GetSoftwareUpdatesResponse
ReadS [GetSoftwareUpdatesResponse]
(Int -> ReadS GetSoftwareUpdatesResponse)
-> ReadS [GetSoftwareUpdatesResponse]
-> ReadPrec GetSoftwareUpdatesResponse
-> ReadPrec [GetSoftwareUpdatesResponse]
-> Read GetSoftwareUpdatesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSoftwareUpdatesResponse]
$creadListPrec :: ReadPrec [GetSoftwareUpdatesResponse]
readPrec :: ReadPrec GetSoftwareUpdatesResponse
$creadPrec :: ReadPrec GetSoftwareUpdatesResponse
readList :: ReadS [GetSoftwareUpdatesResponse]
$creadList :: ReadS [GetSoftwareUpdatesResponse]
readsPrec :: Int -> ReadS GetSoftwareUpdatesResponse
$creadsPrec :: Int -> ReadS GetSoftwareUpdatesResponse
Prelude.Read, Int -> GetSoftwareUpdatesResponse -> ShowS
[GetSoftwareUpdatesResponse] -> ShowS
GetSoftwareUpdatesResponse -> String
(Int -> GetSoftwareUpdatesResponse -> ShowS)
-> (GetSoftwareUpdatesResponse -> String)
-> ([GetSoftwareUpdatesResponse] -> ShowS)
-> Show GetSoftwareUpdatesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSoftwareUpdatesResponse] -> ShowS
$cshowList :: [GetSoftwareUpdatesResponse] -> ShowS
show :: GetSoftwareUpdatesResponse -> String
$cshow :: GetSoftwareUpdatesResponse -> String
showsPrec :: Int -> GetSoftwareUpdatesResponse -> ShowS
$cshowsPrec :: Int -> GetSoftwareUpdatesResponse -> ShowS
Prelude.Show, (forall x.
 GetSoftwareUpdatesResponse -> Rep GetSoftwareUpdatesResponse x)
-> (forall x.
    Rep GetSoftwareUpdatesResponse x -> GetSoftwareUpdatesResponse)
-> Generic GetSoftwareUpdatesResponse
forall x.
Rep GetSoftwareUpdatesResponse x -> GetSoftwareUpdatesResponse
forall x.
GetSoftwareUpdatesResponse -> Rep GetSoftwareUpdatesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetSoftwareUpdatesResponse x -> GetSoftwareUpdatesResponse
$cfrom :: forall x.
GetSoftwareUpdatesResponse -> Rep GetSoftwareUpdatesResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetSoftwareUpdatesResponse' 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:
--
-- 'updatesURI', 'getSoftwareUpdatesResponse_updatesURI' - The Amazon S3 presigned URL for the update file associated with the
-- specified @JobId@ value. The software update will be available for 2
-- days after this request is made. To access an update after the 2 days
-- have passed, you\'ll have to make another call to @GetSoftwareUpdates@.
--
-- 'httpStatus', 'getSoftwareUpdatesResponse_httpStatus' - The response's http status code.
newGetSoftwareUpdatesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSoftwareUpdatesResponse
newGetSoftwareUpdatesResponse :: Int -> GetSoftwareUpdatesResponse
newGetSoftwareUpdatesResponse Int
pHttpStatus_ =
  GetSoftwareUpdatesResponse' :: Maybe Text -> Int -> GetSoftwareUpdatesResponse
GetSoftwareUpdatesResponse'
    { $sel:updatesURI:GetSoftwareUpdatesResponse' :: Maybe Text
updatesURI =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSoftwareUpdatesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon S3 presigned URL for the update file associated with the
-- specified @JobId@ value. The software update will be available for 2
-- days after this request is made. To access an update after the 2 days
-- have passed, you\'ll have to make another call to @GetSoftwareUpdates@.
getSoftwareUpdatesResponse_updatesURI :: Lens.Lens' GetSoftwareUpdatesResponse (Prelude.Maybe Prelude.Text)
getSoftwareUpdatesResponse_updatesURI :: (Maybe Text -> f (Maybe Text))
-> GetSoftwareUpdatesResponse -> f GetSoftwareUpdatesResponse
getSoftwareUpdatesResponse_updatesURI = (GetSoftwareUpdatesResponse -> Maybe Text)
-> (GetSoftwareUpdatesResponse
    -> Maybe Text -> GetSoftwareUpdatesResponse)
-> Lens
     GetSoftwareUpdatesResponse
     GetSoftwareUpdatesResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSoftwareUpdatesResponse' {Maybe Text
updatesURI :: Maybe Text
$sel:updatesURI:GetSoftwareUpdatesResponse' :: GetSoftwareUpdatesResponse -> Maybe Text
updatesURI} -> Maybe Text
updatesURI) (\s :: GetSoftwareUpdatesResponse
s@GetSoftwareUpdatesResponse' {} Maybe Text
a -> GetSoftwareUpdatesResponse
s {$sel:updatesURI:GetSoftwareUpdatesResponse' :: Maybe Text
updatesURI = Maybe Text
a} :: GetSoftwareUpdatesResponse)

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

instance Prelude.NFData GetSoftwareUpdatesResponse