{-# 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.CognitoIdentityProvider.AdminGetDevice
-- 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)
--
-- Gets the device, as an administrator.
--
-- Calling this action requires developer credentials.
module Amazonka.CognitoIdentityProvider.AdminGetDevice
  ( -- * Creating a Request
    AdminGetDevice (..),
    newAdminGetDevice,

    -- * Request Lenses
    adminGetDevice_deviceKey,
    adminGetDevice_userPoolId,
    adminGetDevice_username,

    -- * Destructuring the Response
    AdminGetDeviceResponse (..),
    newAdminGetDeviceResponse,

    -- * Response Lenses
    adminGetDeviceResponse_httpStatus,
    adminGetDeviceResponse_device,
  )
where

import Amazonka.CognitoIdentityProvider.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

-- | Represents the request to get the device, as an administrator.
--
-- /See:/ 'newAdminGetDevice' smart constructor.
data AdminGetDevice = AdminGetDevice'
  { -- | The device key.
    AdminGetDevice -> Text
deviceKey :: Prelude.Text,
    -- | The user pool ID.
    AdminGetDevice -> Text
userPoolId :: Prelude.Text,
    -- | The user name.
    AdminGetDevice -> Sensitive Text
username :: Core.Sensitive Prelude.Text
  }
  deriving (AdminGetDevice -> AdminGetDevice -> Bool
(AdminGetDevice -> AdminGetDevice -> Bool)
-> (AdminGetDevice -> AdminGetDevice -> Bool) -> Eq AdminGetDevice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdminGetDevice -> AdminGetDevice -> Bool
$c/= :: AdminGetDevice -> AdminGetDevice -> Bool
== :: AdminGetDevice -> AdminGetDevice -> Bool
$c== :: AdminGetDevice -> AdminGetDevice -> Bool
Prelude.Eq, Int -> AdminGetDevice -> ShowS
[AdminGetDevice] -> ShowS
AdminGetDevice -> String
(Int -> AdminGetDevice -> ShowS)
-> (AdminGetDevice -> String)
-> ([AdminGetDevice] -> ShowS)
-> Show AdminGetDevice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdminGetDevice] -> ShowS
$cshowList :: [AdminGetDevice] -> ShowS
show :: AdminGetDevice -> String
$cshow :: AdminGetDevice -> String
showsPrec :: Int -> AdminGetDevice -> ShowS
$cshowsPrec :: Int -> AdminGetDevice -> ShowS
Prelude.Show, (forall x. AdminGetDevice -> Rep AdminGetDevice x)
-> (forall x. Rep AdminGetDevice x -> AdminGetDevice)
-> Generic AdminGetDevice
forall x. Rep AdminGetDevice x -> AdminGetDevice
forall x. AdminGetDevice -> Rep AdminGetDevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AdminGetDevice x -> AdminGetDevice
$cfrom :: forall x. AdminGetDevice -> Rep AdminGetDevice x
Prelude.Generic)

-- |
-- Create a value of 'AdminGetDevice' 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:
--
-- 'deviceKey', 'adminGetDevice_deviceKey' - The device key.
--
-- 'userPoolId', 'adminGetDevice_userPoolId' - The user pool ID.
--
-- 'username', 'adminGetDevice_username' - The user name.
newAdminGetDevice ::
  -- | 'deviceKey'
  Prelude.Text ->
  -- | 'userPoolId'
  Prelude.Text ->
  -- | 'username'
  Prelude.Text ->
  AdminGetDevice
newAdminGetDevice :: Text -> Text -> Text -> AdminGetDevice
newAdminGetDevice Text
pDeviceKey_ Text
pUserPoolId_ Text
pUsername_ =
  AdminGetDevice' :: Text -> Text -> Sensitive Text -> AdminGetDevice
AdminGetDevice'
    { $sel:deviceKey:AdminGetDevice' :: Text
deviceKey = Text
pDeviceKey_,
      $sel:userPoolId:AdminGetDevice' :: Text
userPoolId = Text
pUserPoolId_,
      $sel:username:AdminGetDevice' :: Sensitive Text
username = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pUsername_
    }

-- | The device key.
adminGetDevice_deviceKey :: Lens.Lens' AdminGetDevice Prelude.Text
adminGetDevice_deviceKey :: (Text -> f Text) -> AdminGetDevice -> f AdminGetDevice
adminGetDevice_deviceKey = (AdminGetDevice -> Text)
-> (AdminGetDevice -> Text -> AdminGetDevice)
-> Lens AdminGetDevice AdminGetDevice Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminGetDevice' {Text
deviceKey :: Text
$sel:deviceKey:AdminGetDevice' :: AdminGetDevice -> Text
deviceKey} -> Text
deviceKey) (\s :: AdminGetDevice
s@AdminGetDevice' {} Text
a -> AdminGetDevice
s {$sel:deviceKey:AdminGetDevice' :: Text
deviceKey = Text
a} :: AdminGetDevice)

-- | The user pool ID.
adminGetDevice_userPoolId :: Lens.Lens' AdminGetDevice Prelude.Text
adminGetDevice_userPoolId :: (Text -> f Text) -> AdminGetDevice -> f AdminGetDevice
adminGetDevice_userPoolId = (AdminGetDevice -> Text)
-> (AdminGetDevice -> Text -> AdminGetDevice)
-> Lens AdminGetDevice AdminGetDevice Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminGetDevice' {Text
userPoolId :: Text
$sel:userPoolId:AdminGetDevice' :: AdminGetDevice -> Text
userPoolId} -> Text
userPoolId) (\s :: AdminGetDevice
s@AdminGetDevice' {} Text
a -> AdminGetDevice
s {$sel:userPoolId:AdminGetDevice' :: Text
userPoolId = Text
a} :: AdminGetDevice)

-- | The user name.
adminGetDevice_username :: Lens.Lens' AdminGetDevice Prelude.Text
adminGetDevice_username :: (Text -> f Text) -> AdminGetDevice -> f AdminGetDevice
adminGetDevice_username = (AdminGetDevice -> Sensitive Text)
-> (AdminGetDevice -> Sensitive Text -> AdminGetDevice)
-> Lens
     AdminGetDevice AdminGetDevice (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminGetDevice' {Sensitive Text
username :: Sensitive Text
$sel:username:AdminGetDevice' :: AdminGetDevice -> Sensitive Text
username} -> Sensitive Text
username) (\s :: AdminGetDevice
s@AdminGetDevice' {} Sensitive Text
a -> AdminGetDevice
s {$sel:username:AdminGetDevice' :: Sensitive Text
username = Sensitive Text
a} :: AdminGetDevice) ((Sensitive Text -> f (Sensitive Text))
 -> AdminGetDevice -> f AdminGetDevice)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> AdminGetDevice
-> f AdminGetDevice
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

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

instance Prelude.Hashable AdminGetDevice

instance Prelude.NFData AdminGetDevice

instance Core.ToHeaders AdminGetDevice where
  toHeaders :: AdminGetDevice -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AdminGetDevice -> 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
"AWSCognitoIdentityProviderService.AdminGetDevice" ::
                          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 AdminGetDevice where
  toJSON :: AdminGetDevice -> Value
toJSON AdminGetDevice' {Text
Sensitive Text
username :: Sensitive Text
userPoolId :: Text
deviceKey :: Text
$sel:username:AdminGetDevice' :: AdminGetDevice -> Sensitive Text
$sel:userPoolId:AdminGetDevice' :: AdminGetDevice -> Text
$sel:deviceKey:AdminGetDevice' :: AdminGetDevice -> 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
"DeviceKey" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
deviceKey),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UserPoolId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userPoolId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Username" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
username)
          ]
      )

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

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

-- | Gets the device response, as an administrator.
--
-- /See:/ 'newAdminGetDeviceResponse' smart constructor.
data AdminGetDeviceResponse = AdminGetDeviceResponse'
  { -- | The response's http status code.
    AdminGetDeviceResponse -> Int
httpStatus :: Prelude.Int,
    -- | The device.
    AdminGetDeviceResponse -> DeviceType
device :: DeviceType
  }
  deriving (AdminGetDeviceResponse -> AdminGetDeviceResponse -> Bool
(AdminGetDeviceResponse -> AdminGetDeviceResponse -> Bool)
-> (AdminGetDeviceResponse -> AdminGetDeviceResponse -> Bool)
-> Eq AdminGetDeviceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdminGetDeviceResponse -> AdminGetDeviceResponse -> Bool
$c/= :: AdminGetDeviceResponse -> AdminGetDeviceResponse -> Bool
== :: AdminGetDeviceResponse -> AdminGetDeviceResponse -> Bool
$c== :: AdminGetDeviceResponse -> AdminGetDeviceResponse -> Bool
Prelude.Eq, Int -> AdminGetDeviceResponse -> ShowS
[AdminGetDeviceResponse] -> ShowS
AdminGetDeviceResponse -> String
(Int -> AdminGetDeviceResponse -> ShowS)
-> (AdminGetDeviceResponse -> String)
-> ([AdminGetDeviceResponse] -> ShowS)
-> Show AdminGetDeviceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdminGetDeviceResponse] -> ShowS
$cshowList :: [AdminGetDeviceResponse] -> ShowS
show :: AdminGetDeviceResponse -> String
$cshow :: AdminGetDeviceResponse -> String
showsPrec :: Int -> AdminGetDeviceResponse -> ShowS
$cshowsPrec :: Int -> AdminGetDeviceResponse -> ShowS
Prelude.Show, (forall x. AdminGetDeviceResponse -> Rep AdminGetDeviceResponse x)
-> (forall x.
    Rep AdminGetDeviceResponse x -> AdminGetDeviceResponse)
-> Generic AdminGetDeviceResponse
forall x. Rep AdminGetDeviceResponse x -> AdminGetDeviceResponse
forall x. AdminGetDeviceResponse -> Rep AdminGetDeviceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AdminGetDeviceResponse x -> AdminGetDeviceResponse
$cfrom :: forall x. AdminGetDeviceResponse -> Rep AdminGetDeviceResponse x
Prelude.Generic)

-- |
-- Create a value of 'AdminGetDeviceResponse' 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', 'adminGetDeviceResponse_httpStatus' - The response's http status code.
--
-- 'device', 'adminGetDeviceResponse_device' - The device.
newAdminGetDeviceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'device'
  DeviceType ->
  AdminGetDeviceResponse
newAdminGetDeviceResponse :: Int -> DeviceType -> AdminGetDeviceResponse
newAdminGetDeviceResponse Int
pHttpStatus_ DeviceType
pDevice_ =
  AdminGetDeviceResponse' :: Int -> DeviceType -> AdminGetDeviceResponse
AdminGetDeviceResponse'
    { $sel:httpStatus:AdminGetDeviceResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:device:AdminGetDeviceResponse' :: DeviceType
device = DeviceType
pDevice_
    }

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

-- | The device.
adminGetDeviceResponse_device :: Lens.Lens' AdminGetDeviceResponse DeviceType
adminGetDeviceResponse_device :: (DeviceType -> f DeviceType)
-> AdminGetDeviceResponse -> f AdminGetDeviceResponse
adminGetDeviceResponse_device = (AdminGetDeviceResponse -> DeviceType)
-> (AdminGetDeviceResponse -> DeviceType -> AdminGetDeviceResponse)
-> Lens
     AdminGetDeviceResponse AdminGetDeviceResponse DeviceType DeviceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminGetDeviceResponse' {DeviceType
device :: DeviceType
$sel:device:AdminGetDeviceResponse' :: AdminGetDeviceResponse -> DeviceType
device} -> DeviceType
device) (\s :: AdminGetDeviceResponse
s@AdminGetDeviceResponse' {} DeviceType
a -> AdminGetDeviceResponse
s {$sel:device:AdminGetDeviceResponse' :: DeviceType
device = DeviceType
a} :: AdminGetDeviceResponse)

instance Prelude.NFData AdminGetDeviceResponse