{-# 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.MediaLive.TransferInputDevice
-- 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)
--
-- Start an input device transfer to another AWS account. After you make
-- the request, the other account must accept or reject the transfer.
module Amazonka.MediaLive.TransferInputDevice
  ( -- * Creating a Request
    TransferInputDevice' (..),
    newTransferInputDevice',

    -- * Request Lenses
    transferInputDevice'_targetRegion,
    transferInputDevice'_transferMessage,
    transferInputDevice'_targetCustomerId,
    transferInputDevice'_inputDeviceId,

    -- * Destructuring the Response
    TransferInputDeviceResponse (..),
    newTransferInputDeviceResponse,

    -- * Response Lenses
    transferInputDeviceResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | A request to transfer an input device.
--
-- /See:/ 'newTransferInputDevice'' smart constructor.
data TransferInputDevice' = TransferInputDevice''
  { -- | The target AWS region to transfer the device.
    TransferInputDevice' -> Maybe Text
targetRegion :: Prelude.Maybe Prelude.Text,
    -- | An optional message for the recipient. Maximum 280 characters.
    TransferInputDevice' -> Maybe Text
transferMessage :: Prelude.Maybe Prelude.Text,
    -- | The AWS account ID (12 digits) for the recipient of the device transfer.
    TransferInputDevice' -> Maybe Text
targetCustomerId :: Prelude.Maybe Prelude.Text,
    -- | The unique ID of this input device. For example, hd-123456789abcdef.
    TransferInputDevice' -> Text
inputDeviceId :: Prelude.Text
  }
  deriving (TransferInputDevice' -> TransferInputDevice' -> Bool
(TransferInputDevice' -> TransferInputDevice' -> Bool)
-> (TransferInputDevice' -> TransferInputDevice' -> Bool)
-> Eq TransferInputDevice'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransferInputDevice' -> TransferInputDevice' -> Bool
$c/= :: TransferInputDevice' -> TransferInputDevice' -> Bool
== :: TransferInputDevice' -> TransferInputDevice' -> Bool
$c== :: TransferInputDevice' -> TransferInputDevice' -> Bool
Prelude.Eq, ReadPrec [TransferInputDevice']
ReadPrec TransferInputDevice'
Int -> ReadS TransferInputDevice'
ReadS [TransferInputDevice']
(Int -> ReadS TransferInputDevice')
-> ReadS [TransferInputDevice']
-> ReadPrec TransferInputDevice'
-> ReadPrec [TransferInputDevice']
-> Read TransferInputDevice'
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TransferInputDevice']
$creadListPrec :: ReadPrec [TransferInputDevice']
readPrec :: ReadPrec TransferInputDevice'
$creadPrec :: ReadPrec TransferInputDevice'
readList :: ReadS [TransferInputDevice']
$creadList :: ReadS [TransferInputDevice']
readsPrec :: Int -> ReadS TransferInputDevice'
$creadsPrec :: Int -> ReadS TransferInputDevice'
Prelude.Read, Int -> TransferInputDevice' -> ShowS
[TransferInputDevice'] -> ShowS
TransferInputDevice' -> String
(Int -> TransferInputDevice' -> ShowS)
-> (TransferInputDevice' -> String)
-> ([TransferInputDevice'] -> ShowS)
-> Show TransferInputDevice'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransferInputDevice'] -> ShowS
$cshowList :: [TransferInputDevice'] -> ShowS
show :: TransferInputDevice' -> String
$cshow :: TransferInputDevice' -> String
showsPrec :: Int -> TransferInputDevice' -> ShowS
$cshowsPrec :: Int -> TransferInputDevice' -> ShowS
Prelude.Show, (forall x. TransferInputDevice' -> Rep TransferInputDevice' x)
-> (forall x. Rep TransferInputDevice' x -> TransferInputDevice')
-> Generic TransferInputDevice'
forall x. Rep TransferInputDevice' x -> TransferInputDevice'
forall x. TransferInputDevice' -> Rep TransferInputDevice' x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TransferInputDevice' x -> TransferInputDevice'
$cfrom :: forall x. TransferInputDevice' -> Rep TransferInputDevice' x
Prelude.Generic)

-- |
-- Create a value of 'TransferInputDevice'' 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:
--
-- 'targetRegion', 'transferInputDevice'_targetRegion' - The target AWS region to transfer the device.
--
-- 'transferMessage', 'transferInputDevice'_transferMessage' - An optional message for the recipient. Maximum 280 characters.
--
-- 'targetCustomerId', 'transferInputDevice'_targetCustomerId' - The AWS account ID (12 digits) for the recipient of the device transfer.
--
-- 'inputDeviceId', 'transferInputDevice'_inputDeviceId' - The unique ID of this input device. For example, hd-123456789abcdef.
newTransferInputDevice' ::
  -- | 'inputDeviceId'
  Prelude.Text ->
  TransferInputDevice'
newTransferInputDevice' :: Text -> TransferInputDevice'
newTransferInputDevice' Text
pInputDeviceId_ =
  TransferInputDevice'' :: Maybe Text
-> Maybe Text -> Maybe Text -> Text -> TransferInputDevice'
TransferInputDevice''
    { $sel:targetRegion:TransferInputDevice'' :: Maybe Text
targetRegion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:transferMessage:TransferInputDevice'' :: Maybe Text
transferMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetCustomerId:TransferInputDevice'' :: Maybe Text
targetCustomerId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:inputDeviceId:TransferInputDevice'' :: Text
inputDeviceId = Text
pInputDeviceId_
    }

-- | The target AWS region to transfer the device.
transferInputDevice'_targetRegion :: Lens.Lens' TransferInputDevice' (Prelude.Maybe Prelude.Text)
transferInputDevice'_targetRegion :: (Maybe Text -> f (Maybe Text))
-> TransferInputDevice' -> f TransferInputDevice'
transferInputDevice'_targetRegion = (TransferInputDevice' -> Maybe Text)
-> (TransferInputDevice' -> Maybe Text -> TransferInputDevice')
-> Lens
     TransferInputDevice' TransferInputDevice' (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransferInputDevice'' {Maybe Text
targetRegion :: Maybe Text
$sel:targetRegion:TransferInputDevice'' :: TransferInputDevice' -> Maybe Text
targetRegion} -> Maybe Text
targetRegion) (\s :: TransferInputDevice'
s@TransferInputDevice'' {} Maybe Text
a -> TransferInputDevice'
s {$sel:targetRegion:TransferInputDevice'' :: Maybe Text
targetRegion = Maybe Text
a} :: TransferInputDevice')

-- | An optional message for the recipient. Maximum 280 characters.
transferInputDevice'_transferMessage :: Lens.Lens' TransferInputDevice' (Prelude.Maybe Prelude.Text)
transferInputDevice'_transferMessage :: (Maybe Text -> f (Maybe Text))
-> TransferInputDevice' -> f TransferInputDevice'
transferInputDevice'_transferMessage = (TransferInputDevice' -> Maybe Text)
-> (TransferInputDevice' -> Maybe Text -> TransferInputDevice')
-> Lens
     TransferInputDevice' TransferInputDevice' (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransferInputDevice'' {Maybe Text
transferMessage :: Maybe Text
$sel:transferMessage:TransferInputDevice'' :: TransferInputDevice' -> Maybe Text
transferMessage} -> Maybe Text
transferMessage) (\s :: TransferInputDevice'
s@TransferInputDevice'' {} Maybe Text
a -> TransferInputDevice'
s {$sel:transferMessage:TransferInputDevice'' :: Maybe Text
transferMessage = Maybe Text
a} :: TransferInputDevice')

-- | The AWS account ID (12 digits) for the recipient of the device transfer.
transferInputDevice'_targetCustomerId :: Lens.Lens' TransferInputDevice' (Prelude.Maybe Prelude.Text)
transferInputDevice'_targetCustomerId :: (Maybe Text -> f (Maybe Text))
-> TransferInputDevice' -> f TransferInputDevice'
transferInputDevice'_targetCustomerId = (TransferInputDevice' -> Maybe Text)
-> (TransferInputDevice' -> Maybe Text -> TransferInputDevice')
-> Lens
     TransferInputDevice' TransferInputDevice' (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransferInputDevice'' {Maybe Text
targetCustomerId :: Maybe Text
$sel:targetCustomerId:TransferInputDevice'' :: TransferInputDevice' -> Maybe Text
targetCustomerId} -> Maybe Text
targetCustomerId) (\s :: TransferInputDevice'
s@TransferInputDevice'' {} Maybe Text
a -> TransferInputDevice'
s {$sel:targetCustomerId:TransferInputDevice'' :: Maybe Text
targetCustomerId = Maybe Text
a} :: TransferInputDevice')

-- | The unique ID of this input device. For example, hd-123456789abcdef.
transferInputDevice'_inputDeviceId :: Lens.Lens' TransferInputDevice' Prelude.Text
transferInputDevice'_inputDeviceId :: (Text -> f Text) -> TransferInputDevice' -> f TransferInputDevice'
transferInputDevice'_inputDeviceId = (TransferInputDevice' -> Text)
-> (TransferInputDevice' -> Text -> TransferInputDevice')
-> Lens TransferInputDevice' TransferInputDevice' Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransferInputDevice'' {Text
inputDeviceId :: Text
$sel:inputDeviceId:TransferInputDevice'' :: TransferInputDevice' -> Text
inputDeviceId} -> Text
inputDeviceId) (\s :: TransferInputDevice'
s@TransferInputDevice'' {} Text
a -> TransferInputDevice'
s {$sel:inputDeviceId:TransferInputDevice'' :: Text
inputDeviceId = Text
a} :: TransferInputDevice')

instance Core.AWSRequest TransferInputDevice' where
  type
    AWSResponse TransferInputDevice' =
      TransferInputDeviceResponse
  request :: TransferInputDevice' -> Request TransferInputDevice'
request = Service -> TransferInputDevice' -> Request TransferInputDevice'
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy TransferInputDevice'
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse TransferInputDevice')))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse TransferInputDevice'))
-> Logger
-> Service
-> Proxy TransferInputDevice'
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse TransferInputDevice')))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> TransferInputDeviceResponse
TransferInputDeviceResponse'
            (Int -> TransferInputDeviceResponse)
-> Either String Int -> Either String TransferInputDeviceResponse
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))
      )

instance Prelude.Hashable TransferInputDevice'

instance Prelude.NFData TransferInputDevice'

instance Core.ToHeaders TransferInputDevice' where
  toHeaders :: TransferInputDevice' -> ResponseHeaders
toHeaders =
    ResponseHeaders -> TransferInputDevice' -> 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.ToJSON TransferInputDevice' where
  toJSON :: TransferInputDevice' -> Value
toJSON TransferInputDevice'' {Maybe Text
Text
inputDeviceId :: Text
targetCustomerId :: Maybe Text
transferMessage :: Maybe Text
targetRegion :: Maybe Text
$sel:inputDeviceId:TransferInputDevice'' :: TransferInputDevice' -> Text
$sel:targetCustomerId:TransferInputDevice'' :: TransferInputDevice' -> Maybe Text
$sel:transferMessage:TransferInputDevice'' :: TransferInputDevice' -> Maybe Text
$sel:targetRegion:TransferInputDevice'' :: TransferInputDevice' -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"targetRegion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
targetRegion,
            (Text
"transferMessage" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
transferMessage,
            (Text
"targetCustomerId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
targetCustomerId
          ]
      )

instance Core.ToPath TransferInputDevice' where
  toPath :: TransferInputDevice' -> ByteString
toPath TransferInputDevice'' {Maybe Text
Text
inputDeviceId :: Text
targetCustomerId :: Maybe Text
transferMessage :: Maybe Text
targetRegion :: Maybe Text
$sel:inputDeviceId:TransferInputDevice'' :: TransferInputDevice' -> Text
$sel:targetCustomerId:TransferInputDevice'' :: TransferInputDevice' -> Maybe Text
$sel:transferMessage:TransferInputDevice'' :: TransferInputDevice' -> Maybe Text
$sel:targetRegion:TransferInputDevice'' :: TransferInputDevice' -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/prod/inputDevices/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
inputDeviceId,
        ByteString
"/transfer"
      ]

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

-- | Placeholder documentation for TransferInputDeviceResponse
--
-- /See:/ 'newTransferInputDeviceResponse' smart constructor.
data TransferInputDeviceResponse = TransferInputDeviceResponse'
  { -- | The response's http status code.
    TransferInputDeviceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (TransferInputDeviceResponse -> TransferInputDeviceResponse -> Bool
(TransferInputDeviceResponse
 -> TransferInputDeviceResponse -> Bool)
-> (TransferInputDeviceResponse
    -> TransferInputDeviceResponse -> Bool)
-> Eq TransferInputDeviceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransferInputDeviceResponse -> TransferInputDeviceResponse -> Bool
$c/= :: TransferInputDeviceResponse -> TransferInputDeviceResponse -> Bool
== :: TransferInputDeviceResponse -> TransferInputDeviceResponse -> Bool
$c== :: TransferInputDeviceResponse -> TransferInputDeviceResponse -> Bool
Prelude.Eq, ReadPrec [TransferInputDeviceResponse]
ReadPrec TransferInputDeviceResponse
Int -> ReadS TransferInputDeviceResponse
ReadS [TransferInputDeviceResponse]
(Int -> ReadS TransferInputDeviceResponse)
-> ReadS [TransferInputDeviceResponse]
-> ReadPrec TransferInputDeviceResponse
-> ReadPrec [TransferInputDeviceResponse]
-> Read TransferInputDeviceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TransferInputDeviceResponse]
$creadListPrec :: ReadPrec [TransferInputDeviceResponse]
readPrec :: ReadPrec TransferInputDeviceResponse
$creadPrec :: ReadPrec TransferInputDeviceResponse
readList :: ReadS [TransferInputDeviceResponse]
$creadList :: ReadS [TransferInputDeviceResponse]
readsPrec :: Int -> ReadS TransferInputDeviceResponse
$creadsPrec :: Int -> ReadS TransferInputDeviceResponse
Prelude.Read, Int -> TransferInputDeviceResponse -> ShowS
[TransferInputDeviceResponse] -> ShowS
TransferInputDeviceResponse -> String
(Int -> TransferInputDeviceResponse -> ShowS)
-> (TransferInputDeviceResponse -> String)
-> ([TransferInputDeviceResponse] -> ShowS)
-> Show TransferInputDeviceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransferInputDeviceResponse] -> ShowS
$cshowList :: [TransferInputDeviceResponse] -> ShowS
show :: TransferInputDeviceResponse -> String
$cshow :: TransferInputDeviceResponse -> String
showsPrec :: Int -> TransferInputDeviceResponse -> ShowS
$cshowsPrec :: Int -> TransferInputDeviceResponse -> ShowS
Prelude.Show, (forall x.
 TransferInputDeviceResponse -> Rep TransferInputDeviceResponse x)
-> (forall x.
    Rep TransferInputDeviceResponse x -> TransferInputDeviceResponse)
-> Generic TransferInputDeviceResponse
forall x.
Rep TransferInputDeviceResponse x -> TransferInputDeviceResponse
forall x.
TransferInputDeviceResponse -> Rep TransferInputDeviceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TransferInputDeviceResponse x -> TransferInputDeviceResponse
$cfrom :: forall x.
TransferInputDeviceResponse -> Rep TransferInputDeviceResponse x
Prelude.Generic)

-- |
-- Create a value of 'TransferInputDeviceResponse' 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', 'transferInputDeviceResponse_httpStatus' - The response's http status code.
newTransferInputDeviceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  TransferInputDeviceResponse
newTransferInputDeviceResponse :: Int -> TransferInputDeviceResponse
newTransferInputDeviceResponse Int
pHttpStatus_ =
  TransferInputDeviceResponse' :: Int -> TransferInputDeviceResponse
TransferInputDeviceResponse'
    { $sel:httpStatus:TransferInputDeviceResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData TransferInputDeviceResponse