{-# 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.DirectoryService.Types.Computer
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DirectoryService.Types.Computer where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DirectoryService.Types.Attribute
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a computer account in a directory.
--
-- /See:/ 'newComputer' smart constructor.
data Computer = Computer'
  { -- | An array of Attribute objects containing the LDAP attributes that belong
    -- to the computer account.
    Computer -> Maybe [Attribute]
computerAttributes :: Prelude.Maybe [Attribute],
    -- | The identifier of the computer.
    Computer -> Maybe Text
computerId :: Prelude.Maybe Prelude.Text,
    -- | The computer name.
    Computer -> Maybe Text
computerName :: Prelude.Maybe Prelude.Text
  }
  deriving (Computer -> Computer -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Computer -> Computer -> Bool
$c/= :: Computer -> Computer -> Bool
== :: Computer -> Computer -> Bool
$c== :: Computer -> Computer -> Bool
Prelude.Eq, ReadPrec [Computer]
ReadPrec Computer
Int -> ReadS Computer
ReadS [Computer]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Computer]
$creadListPrec :: ReadPrec [Computer]
readPrec :: ReadPrec Computer
$creadPrec :: ReadPrec Computer
readList :: ReadS [Computer]
$creadList :: ReadS [Computer]
readsPrec :: Int -> ReadS Computer
$creadsPrec :: Int -> ReadS Computer
Prelude.Read, Int -> Computer -> ShowS
[Computer] -> ShowS
Computer -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Computer] -> ShowS
$cshowList :: [Computer] -> ShowS
show :: Computer -> String
$cshow :: Computer -> String
showsPrec :: Int -> Computer -> ShowS
$cshowsPrec :: Int -> Computer -> ShowS
Prelude.Show, forall x. Rep Computer x -> Computer
forall x. Computer -> Rep Computer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Computer x -> Computer
$cfrom :: forall x. Computer -> Rep Computer x
Prelude.Generic)

-- |
-- Create a value of 'Computer' 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:
--
-- 'computerAttributes', 'computer_computerAttributes' - An array of Attribute objects containing the LDAP attributes that belong
-- to the computer account.
--
-- 'computerId', 'computer_computerId' - The identifier of the computer.
--
-- 'computerName', 'computer_computerName' - The computer name.
newComputer ::
  Computer
newComputer :: Computer
newComputer =
  Computer'
    { $sel:computerAttributes:Computer' :: Maybe [Attribute]
computerAttributes = forall a. Maybe a
Prelude.Nothing,
      $sel:computerId:Computer' :: Maybe Text
computerId = forall a. Maybe a
Prelude.Nothing,
      $sel:computerName:Computer' :: Maybe Text
computerName = forall a. Maybe a
Prelude.Nothing
    }

-- | An array of Attribute objects containing the LDAP attributes that belong
-- to the computer account.
computer_computerAttributes :: Lens.Lens' Computer (Prelude.Maybe [Attribute])
computer_computerAttributes :: Lens' Computer (Maybe [Attribute])
computer_computerAttributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Computer' {Maybe [Attribute]
computerAttributes :: Maybe [Attribute]
$sel:computerAttributes:Computer' :: Computer -> Maybe [Attribute]
computerAttributes} -> Maybe [Attribute]
computerAttributes) (\s :: Computer
s@Computer' {} Maybe [Attribute]
a -> Computer
s {$sel:computerAttributes:Computer' :: Maybe [Attribute]
computerAttributes = Maybe [Attribute]
a} :: Computer) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The identifier of the computer.
computer_computerId :: Lens.Lens' Computer (Prelude.Maybe Prelude.Text)
computer_computerId :: Lens' Computer (Maybe Text)
computer_computerId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Computer' {Maybe Text
computerId :: Maybe Text
$sel:computerId:Computer' :: Computer -> Maybe Text
computerId} -> Maybe Text
computerId) (\s :: Computer
s@Computer' {} Maybe Text
a -> Computer
s {$sel:computerId:Computer' :: Maybe Text
computerId = Maybe Text
a} :: Computer)

-- | The computer name.
computer_computerName :: Lens.Lens' Computer (Prelude.Maybe Prelude.Text)
computer_computerName :: Lens' Computer (Maybe Text)
computer_computerName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Computer' {Maybe Text
computerName :: Maybe Text
$sel:computerName:Computer' :: Computer -> Maybe Text
computerName} -> Maybe Text
computerName) (\s :: Computer
s@Computer' {} Maybe Text
a -> Computer
s {$sel:computerName:Computer' :: Maybe Text
computerName = Maybe Text
a} :: Computer)

instance Data.FromJSON Computer where
  parseJSON :: Value -> Parser Computer
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Computer"
      ( \Object
x ->
          Maybe [Attribute] -> Maybe Text -> Maybe Text -> Computer
Computer'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ComputerAttributes"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ComputerId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ComputerName")
      )

instance Prelude.Hashable Computer where
  hashWithSalt :: Int -> Computer -> Int
hashWithSalt Int
_salt Computer' {Maybe [Attribute]
Maybe Text
computerName :: Maybe Text
computerId :: Maybe Text
computerAttributes :: Maybe [Attribute]
$sel:computerName:Computer' :: Computer -> Maybe Text
$sel:computerId:Computer' :: Computer -> Maybe Text
$sel:computerAttributes:Computer' :: Computer -> Maybe [Attribute]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Attribute]
computerAttributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
computerId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
computerName

instance Prelude.NFData Computer where
  rnf :: Computer -> ()
rnf Computer' {Maybe [Attribute]
Maybe Text
computerName :: Maybe Text
computerId :: Maybe Text
computerAttributes :: Maybe [Attribute]
$sel:computerName:Computer' :: Computer -> Maybe Text
$sel:computerId:Computer' :: Computer -> Maybe Text
$sel:computerAttributes:Computer' :: Computer -> Maybe [Attribute]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Attribute]
computerAttributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
computerId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
computerName