{-# 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.ClaimDevice
-- 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)
--
-- Send a request to claim an AWS Elemental device that you have purchased
-- from a third-party vendor. After the request succeeds, you will own the
-- device.
module Amazonka.MediaLive.ClaimDevice
  ( -- * Creating a Request
    ClaimDevice (..),
    newClaimDevice,

    -- * Request Lenses
    claimDevice_id,

    -- * Destructuring the Response
    ClaimDeviceResponse (..),
    newClaimDeviceResponse,

    -- * Response Lenses
    claimDeviceResponse_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 claim an AWS Elemental device that you have purchased from
-- a third-party vendor.
--
-- /See:/ 'newClaimDevice' smart constructor.
data ClaimDevice = ClaimDevice'
  { -- | The id of the device you want to claim.
    ClaimDevice -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (ClaimDevice -> ClaimDevice -> Bool
(ClaimDevice -> ClaimDevice -> Bool)
-> (ClaimDevice -> ClaimDevice -> Bool) -> Eq ClaimDevice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClaimDevice -> ClaimDevice -> Bool
$c/= :: ClaimDevice -> ClaimDevice -> Bool
== :: ClaimDevice -> ClaimDevice -> Bool
$c== :: ClaimDevice -> ClaimDevice -> Bool
Prelude.Eq, ReadPrec [ClaimDevice]
ReadPrec ClaimDevice
Int -> ReadS ClaimDevice
ReadS [ClaimDevice]
(Int -> ReadS ClaimDevice)
-> ReadS [ClaimDevice]
-> ReadPrec ClaimDevice
-> ReadPrec [ClaimDevice]
-> Read ClaimDevice
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClaimDevice]
$creadListPrec :: ReadPrec [ClaimDevice]
readPrec :: ReadPrec ClaimDevice
$creadPrec :: ReadPrec ClaimDevice
readList :: ReadS [ClaimDevice]
$creadList :: ReadS [ClaimDevice]
readsPrec :: Int -> ReadS ClaimDevice
$creadsPrec :: Int -> ReadS ClaimDevice
Prelude.Read, Int -> ClaimDevice -> ShowS
[ClaimDevice] -> ShowS
ClaimDevice -> String
(Int -> ClaimDevice -> ShowS)
-> (ClaimDevice -> String)
-> ([ClaimDevice] -> ShowS)
-> Show ClaimDevice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClaimDevice] -> ShowS
$cshowList :: [ClaimDevice] -> ShowS
show :: ClaimDevice -> String
$cshow :: ClaimDevice -> String
showsPrec :: Int -> ClaimDevice -> ShowS
$cshowsPrec :: Int -> ClaimDevice -> ShowS
Prelude.Show, (forall x. ClaimDevice -> Rep ClaimDevice x)
-> (forall x. Rep ClaimDevice x -> ClaimDevice)
-> Generic ClaimDevice
forall x. Rep ClaimDevice x -> ClaimDevice
forall x. ClaimDevice -> Rep ClaimDevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClaimDevice x -> ClaimDevice
$cfrom :: forall x. ClaimDevice -> Rep ClaimDevice x
Prelude.Generic)

-- |
-- Create a value of 'ClaimDevice' 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:
--
-- 'id', 'claimDevice_id' - The id of the device you want to claim.
newClaimDevice ::
  ClaimDevice
newClaimDevice :: ClaimDevice
newClaimDevice = ClaimDevice' :: Maybe Text -> ClaimDevice
ClaimDevice' {$sel:id:ClaimDevice' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The id of the device you want to claim.
claimDevice_id :: Lens.Lens' ClaimDevice (Prelude.Maybe Prelude.Text)
claimDevice_id :: (Maybe Text -> f (Maybe Text)) -> ClaimDevice -> f ClaimDevice
claimDevice_id = (ClaimDevice -> Maybe Text)
-> (ClaimDevice -> Maybe Text -> ClaimDevice)
-> Lens ClaimDevice ClaimDevice (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClaimDevice' {Maybe Text
id :: Maybe Text
$sel:id:ClaimDevice' :: ClaimDevice -> Maybe Text
id} -> Maybe Text
id) (\s :: ClaimDevice
s@ClaimDevice' {} Maybe Text
a -> ClaimDevice
s {$sel:id:ClaimDevice' :: Maybe Text
id = Maybe Text
a} :: ClaimDevice)

instance Core.AWSRequest ClaimDevice where
  type AWSResponse ClaimDevice = ClaimDeviceResponse
  request :: ClaimDevice -> Request ClaimDevice
request = Service -> ClaimDevice -> Request ClaimDevice
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ClaimDevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ClaimDevice)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse ClaimDevice))
-> Logger
-> Service
-> Proxy ClaimDevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ClaimDevice)))
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 -> ClaimDeviceResponse
ClaimDeviceResponse'
            (Int -> ClaimDeviceResponse)
-> Either String Int -> Either String ClaimDeviceResponse
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 ClaimDevice

instance Prelude.NFData ClaimDevice

instance Core.ToHeaders ClaimDevice where
  toHeaders :: ClaimDevice -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ClaimDevice -> 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 ClaimDevice where
  toJSON :: ClaimDevice -> Value
toJSON ClaimDevice' {Maybe Text
id :: Maybe Text
$sel:id:ClaimDevice' :: ClaimDevice -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ([Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes [(Text
"id" 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
id])

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

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

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

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

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

instance Prelude.NFData ClaimDeviceResponse