{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.GuardDuty.Types.AccessKeyDetails
-- 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)
module Amazonka.GuardDuty.Types.AccessKeyDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the access keys.
--
-- /See:/ 'newAccessKeyDetails' smart constructor.
data AccessKeyDetails = AccessKeyDetails'
  { -- | The principal ID of the user.
    AccessKeyDetails -> Maybe Text
principalId :: Prelude.Maybe Prelude.Text,
    -- | The name of the user.
    AccessKeyDetails -> Maybe Text
userName :: Prelude.Maybe Prelude.Text,
    -- | The access key ID of the user.
    AccessKeyDetails -> Maybe Text
accessKeyId :: Prelude.Maybe Prelude.Text,
    -- | The type of the user.
    AccessKeyDetails -> Maybe Text
userType :: Prelude.Maybe Prelude.Text
  }
  deriving (AccessKeyDetails -> AccessKeyDetails -> Bool
(AccessKeyDetails -> AccessKeyDetails -> Bool)
-> (AccessKeyDetails -> AccessKeyDetails -> Bool)
-> Eq AccessKeyDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccessKeyDetails -> AccessKeyDetails -> Bool
$c/= :: AccessKeyDetails -> AccessKeyDetails -> Bool
== :: AccessKeyDetails -> AccessKeyDetails -> Bool
$c== :: AccessKeyDetails -> AccessKeyDetails -> Bool
Prelude.Eq, ReadPrec [AccessKeyDetails]
ReadPrec AccessKeyDetails
Int -> ReadS AccessKeyDetails
ReadS [AccessKeyDetails]
(Int -> ReadS AccessKeyDetails)
-> ReadS [AccessKeyDetails]
-> ReadPrec AccessKeyDetails
-> ReadPrec [AccessKeyDetails]
-> Read AccessKeyDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccessKeyDetails]
$creadListPrec :: ReadPrec [AccessKeyDetails]
readPrec :: ReadPrec AccessKeyDetails
$creadPrec :: ReadPrec AccessKeyDetails
readList :: ReadS [AccessKeyDetails]
$creadList :: ReadS [AccessKeyDetails]
readsPrec :: Int -> ReadS AccessKeyDetails
$creadsPrec :: Int -> ReadS AccessKeyDetails
Prelude.Read, Int -> AccessKeyDetails -> ShowS
[AccessKeyDetails] -> ShowS
AccessKeyDetails -> String
(Int -> AccessKeyDetails -> ShowS)
-> (AccessKeyDetails -> String)
-> ([AccessKeyDetails] -> ShowS)
-> Show AccessKeyDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccessKeyDetails] -> ShowS
$cshowList :: [AccessKeyDetails] -> ShowS
show :: AccessKeyDetails -> String
$cshow :: AccessKeyDetails -> String
showsPrec :: Int -> AccessKeyDetails -> ShowS
$cshowsPrec :: Int -> AccessKeyDetails -> ShowS
Prelude.Show, (forall x. AccessKeyDetails -> Rep AccessKeyDetails x)
-> (forall x. Rep AccessKeyDetails x -> AccessKeyDetails)
-> Generic AccessKeyDetails
forall x. Rep AccessKeyDetails x -> AccessKeyDetails
forall x. AccessKeyDetails -> Rep AccessKeyDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccessKeyDetails x -> AccessKeyDetails
$cfrom :: forall x. AccessKeyDetails -> Rep AccessKeyDetails x
Prelude.Generic)

-- |
-- Create a value of 'AccessKeyDetails' 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:
--
-- 'principalId', 'accessKeyDetails_principalId' - The principal ID of the user.
--
-- 'userName', 'accessKeyDetails_userName' - The name of the user.
--
-- 'accessKeyId', 'accessKeyDetails_accessKeyId' - The access key ID of the user.
--
-- 'userType', 'accessKeyDetails_userType' - The type of the user.
newAccessKeyDetails ::
  AccessKeyDetails
newAccessKeyDetails :: AccessKeyDetails
newAccessKeyDetails =
  AccessKeyDetails' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> AccessKeyDetails
AccessKeyDetails'
    { $sel:principalId:AccessKeyDetails' :: Maybe Text
principalId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:userName:AccessKeyDetails' :: Maybe Text
userName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accessKeyId:AccessKeyDetails' :: Maybe Text
accessKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:userType:AccessKeyDetails' :: Maybe Text
userType = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The principal ID of the user.
accessKeyDetails_principalId :: Lens.Lens' AccessKeyDetails (Prelude.Maybe Prelude.Text)
accessKeyDetails_principalId :: (Maybe Text -> f (Maybe Text))
-> AccessKeyDetails -> f AccessKeyDetails
accessKeyDetails_principalId = (AccessKeyDetails -> Maybe Text)
-> (AccessKeyDetails -> Maybe Text -> AccessKeyDetails)
-> Lens AccessKeyDetails AccessKeyDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessKeyDetails' {Maybe Text
principalId :: Maybe Text
$sel:principalId:AccessKeyDetails' :: AccessKeyDetails -> Maybe Text
principalId} -> Maybe Text
principalId) (\s :: AccessKeyDetails
s@AccessKeyDetails' {} Maybe Text
a -> AccessKeyDetails
s {$sel:principalId:AccessKeyDetails' :: Maybe Text
principalId = Maybe Text
a} :: AccessKeyDetails)

-- | The name of the user.
accessKeyDetails_userName :: Lens.Lens' AccessKeyDetails (Prelude.Maybe Prelude.Text)
accessKeyDetails_userName :: (Maybe Text -> f (Maybe Text))
-> AccessKeyDetails -> f AccessKeyDetails
accessKeyDetails_userName = (AccessKeyDetails -> Maybe Text)
-> (AccessKeyDetails -> Maybe Text -> AccessKeyDetails)
-> Lens AccessKeyDetails AccessKeyDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessKeyDetails' {Maybe Text
userName :: Maybe Text
$sel:userName:AccessKeyDetails' :: AccessKeyDetails -> Maybe Text
userName} -> Maybe Text
userName) (\s :: AccessKeyDetails
s@AccessKeyDetails' {} Maybe Text
a -> AccessKeyDetails
s {$sel:userName:AccessKeyDetails' :: Maybe Text
userName = Maybe Text
a} :: AccessKeyDetails)

-- | The access key ID of the user.
accessKeyDetails_accessKeyId :: Lens.Lens' AccessKeyDetails (Prelude.Maybe Prelude.Text)
accessKeyDetails_accessKeyId :: (Maybe Text -> f (Maybe Text))
-> AccessKeyDetails -> f AccessKeyDetails
accessKeyDetails_accessKeyId = (AccessKeyDetails -> Maybe Text)
-> (AccessKeyDetails -> Maybe Text -> AccessKeyDetails)
-> Lens AccessKeyDetails AccessKeyDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessKeyDetails' {Maybe Text
accessKeyId :: Maybe Text
$sel:accessKeyId:AccessKeyDetails' :: AccessKeyDetails -> Maybe Text
accessKeyId} -> Maybe Text
accessKeyId) (\s :: AccessKeyDetails
s@AccessKeyDetails' {} Maybe Text
a -> AccessKeyDetails
s {$sel:accessKeyId:AccessKeyDetails' :: Maybe Text
accessKeyId = Maybe Text
a} :: AccessKeyDetails)

-- | The type of the user.
accessKeyDetails_userType :: Lens.Lens' AccessKeyDetails (Prelude.Maybe Prelude.Text)
accessKeyDetails_userType :: (Maybe Text -> f (Maybe Text))
-> AccessKeyDetails -> f AccessKeyDetails
accessKeyDetails_userType = (AccessKeyDetails -> Maybe Text)
-> (AccessKeyDetails -> Maybe Text -> AccessKeyDetails)
-> Lens AccessKeyDetails AccessKeyDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessKeyDetails' {Maybe Text
userType :: Maybe Text
$sel:userType:AccessKeyDetails' :: AccessKeyDetails -> Maybe Text
userType} -> Maybe Text
userType) (\s :: AccessKeyDetails
s@AccessKeyDetails' {} Maybe Text
a -> AccessKeyDetails
s {$sel:userType:AccessKeyDetails' :: Maybe Text
userType = Maybe Text
a} :: AccessKeyDetails)

instance Core.FromJSON AccessKeyDetails where
  parseJSON :: Value -> Parser AccessKeyDetails
parseJSON =
    String
-> (Object -> Parser AccessKeyDetails)
-> Value
-> Parser AccessKeyDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AccessKeyDetails"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> AccessKeyDetails
AccessKeyDetails'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> AccessKeyDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> AccessKeyDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"principalId")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> AccessKeyDetails)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> AccessKeyDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"userName")
            Parser (Maybe Text -> Maybe Text -> AccessKeyDetails)
-> Parser (Maybe Text) -> Parser (Maybe Text -> AccessKeyDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"accessKeyId")
            Parser (Maybe Text -> AccessKeyDetails)
-> Parser (Maybe Text) -> Parser AccessKeyDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"userType")
      )

instance Prelude.Hashable AccessKeyDetails

instance Prelude.NFData AccessKeyDetails