{-# 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.DescribeAddress
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Takes an @AddressId@ and returns specific details about that address in
-- the form of an @Address@ object.
module Amazonka.Snowball.DescribeAddress
  ( -- * Creating a Request
    DescribeAddress (..),
    newDescribeAddress,

    -- * Request Lenses
    describeAddress_addressId,

    -- * Destructuring the Response
    DescribeAddressResponse (..),
    newDescribeAddressResponse,

    -- * Response Lenses
    describeAddressResponse_address,
    describeAddressResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeAddress' smart constructor.
data DescribeAddress = DescribeAddress'
  { -- | The automatically generated ID for a specific address.
    DescribeAddress -> Text
addressId :: Prelude.Text
  }
  deriving (DescribeAddress -> DescribeAddress -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAddress -> DescribeAddress -> Bool
$c/= :: DescribeAddress -> DescribeAddress -> Bool
== :: DescribeAddress -> DescribeAddress -> Bool
$c== :: DescribeAddress -> DescribeAddress -> Bool
Prelude.Eq, ReadPrec [DescribeAddress]
ReadPrec DescribeAddress
Int -> ReadS DescribeAddress
ReadS [DescribeAddress]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAddress]
$creadListPrec :: ReadPrec [DescribeAddress]
readPrec :: ReadPrec DescribeAddress
$creadPrec :: ReadPrec DescribeAddress
readList :: ReadS [DescribeAddress]
$creadList :: ReadS [DescribeAddress]
readsPrec :: Int -> ReadS DescribeAddress
$creadsPrec :: Int -> ReadS DescribeAddress
Prelude.Read, Int -> DescribeAddress -> ShowS
[DescribeAddress] -> ShowS
DescribeAddress -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAddress] -> ShowS
$cshowList :: [DescribeAddress] -> ShowS
show :: DescribeAddress -> String
$cshow :: DescribeAddress -> String
showsPrec :: Int -> DescribeAddress -> ShowS
$cshowsPrec :: Int -> DescribeAddress -> ShowS
Prelude.Show, forall x. Rep DescribeAddress x -> DescribeAddress
forall x. DescribeAddress -> Rep DescribeAddress x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAddress x -> DescribeAddress
$cfrom :: forall x. DescribeAddress -> Rep DescribeAddress x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAddress' 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:
--
-- 'addressId', 'describeAddress_addressId' - The automatically generated ID for a specific address.
newDescribeAddress ::
  -- | 'addressId'
  Prelude.Text ->
  DescribeAddress
newDescribeAddress :: Text -> DescribeAddress
newDescribeAddress Text
pAddressId_ =
  DescribeAddress' {$sel:addressId:DescribeAddress' :: Text
addressId = Text
pAddressId_}

-- | The automatically generated ID for a specific address.
describeAddress_addressId :: Lens.Lens' DescribeAddress Prelude.Text
describeAddress_addressId :: Lens' DescribeAddress Text
describeAddress_addressId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAddress' {Text
addressId :: Text
$sel:addressId:DescribeAddress' :: DescribeAddress -> Text
addressId} -> Text
addressId) (\s :: DescribeAddress
s@DescribeAddress' {} Text
a -> DescribeAddress
s {$sel:addressId:DescribeAddress' :: Text
addressId = Text
a} :: DescribeAddress)

instance Core.AWSRequest DescribeAddress where
  type
    AWSResponse DescribeAddress =
      DescribeAddressResponse
  request :: (Service -> Service) -> DescribeAddress -> Request DescribeAddress
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeAddress
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeAddress)))
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 Address -> Int -> DescribeAddressResponse
DescribeAddressResponse'
            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
"Address")
            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 DescribeAddress where
  hashWithSalt :: Int -> DescribeAddress -> Int
hashWithSalt Int
_salt DescribeAddress' {Text
addressId :: Text
$sel:addressId:DescribeAddress' :: DescribeAddress -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
addressId

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

instance Data.ToHeaders DescribeAddress where
  toHeaders :: DescribeAddress -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSIESnowballJobManagementService.DescribeAddress" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DescribeAddress where
  toJSON :: DescribeAddress -> Value
toJSON DescribeAddress' {Text
addressId :: Text
$sel:addressId:DescribeAddress' :: DescribeAddress -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"AddressId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
addressId)]
      )

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

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

-- | /See:/ 'newDescribeAddressResponse' smart constructor.
data DescribeAddressResponse = DescribeAddressResponse'
  { -- | The address that you want the Snow device(s) associated with a specific
    -- job to be shipped to.
    DescribeAddressResponse -> Maybe Address
address :: Prelude.Maybe Address,
    -- | The response's http status code.
    DescribeAddressResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAddressResponse -> DescribeAddressResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAddressResponse -> DescribeAddressResponse -> Bool
$c/= :: DescribeAddressResponse -> DescribeAddressResponse -> Bool
== :: DescribeAddressResponse -> DescribeAddressResponse -> Bool
$c== :: DescribeAddressResponse -> DescribeAddressResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAddressResponse]
ReadPrec DescribeAddressResponse
Int -> ReadS DescribeAddressResponse
ReadS [DescribeAddressResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAddressResponse]
$creadListPrec :: ReadPrec [DescribeAddressResponse]
readPrec :: ReadPrec DescribeAddressResponse
$creadPrec :: ReadPrec DescribeAddressResponse
readList :: ReadS [DescribeAddressResponse]
$creadList :: ReadS [DescribeAddressResponse]
readsPrec :: Int -> ReadS DescribeAddressResponse
$creadsPrec :: Int -> ReadS DescribeAddressResponse
Prelude.Read, Int -> DescribeAddressResponse -> ShowS
[DescribeAddressResponse] -> ShowS
DescribeAddressResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAddressResponse] -> ShowS
$cshowList :: [DescribeAddressResponse] -> ShowS
show :: DescribeAddressResponse -> String
$cshow :: DescribeAddressResponse -> String
showsPrec :: Int -> DescribeAddressResponse -> ShowS
$cshowsPrec :: Int -> DescribeAddressResponse -> ShowS
Prelude.Show, forall x. Rep DescribeAddressResponse x -> DescribeAddressResponse
forall x. DescribeAddressResponse -> Rep DescribeAddressResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAddressResponse x -> DescribeAddressResponse
$cfrom :: forall x. DescribeAddressResponse -> Rep DescribeAddressResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAddressResponse' 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:
--
-- 'address', 'describeAddressResponse_address' - The address that you want the Snow device(s) associated with a specific
-- job to be shipped to.
--
-- 'httpStatus', 'describeAddressResponse_httpStatus' - The response's http status code.
newDescribeAddressResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAddressResponse
newDescribeAddressResponse :: Int -> DescribeAddressResponse
newDescribeAddressResponse Int
pHttpStatus_ =
  DescribeAddressResponse'
    { $sel:address:DescribeAddressResponse' :: Maybe Address
address = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAddressResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The address that you want the Snow device(s) associated with a specific
-- job to be shipped to.
describeAddressResponse_address :: Lens.Lens' DescribeAddressResponse (Prelude.Maybe Address)
describeAddressResponse_address :: Lens' DescribeAddressResponse (Maybe Address)
describeAddressResponse_address = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAddressResponse' {Maybe Address
address :: Maybe Address
$sel:address:DescribeAddressResponse' :: DescribeAddressResponse -> Maybe Address
address} -> Maybe Address
address) (\s :: DescribeAddressResponse
s@DescribeAddressResponse' {} Maybe Address
a -> DescribeAddressResponse
s {$sel:address:DescribeAddressResponse' :: Maybe Address
address = Maybe Address
a} :: DescribeAddressResponse)

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

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