{-# 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.IAM.Types.ServerCertificate
-- 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.IAM.Types.ServerCertificate where

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types.ServerCertificateMetadata
import Amazonka.IAM.Types.Tag
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a server certificate.
--
-- This data type is used as a response element in the GetServerCertificate
-- operation.
--
-- /See:/ 'newServerCertificate' smart constructor.
data ServerCertificate = ServerCertificate'
  { -- | The contents of the public key certificate chain.
    ServerCertificate -> Maybe Text
certificateChain :: Prelude.Maybe Prelude.Text,
    -- | A list of tags that are attached to the server certificate. For more
    -- information about tagging, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
    -- in the /IAM User Guide/.
    ServerCertificate -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The meta information of the server certificate, such as its name, path,
    -- ID, and ARN.
    ServerCertificate -> ServerCertificateMetadata
serverCertificateMetadata :: ServerCertificateMetadata,
    -- | The contents of the public key certificate.
    ServerCertificate -> Text
certificateBody :: Prelude.Text
  }
  deriving (ServerCertificate -> ServerCertificate -> Bool
(ServerCertificate -> ServerCertificate -> Bool)
-> (ServerCertificate -> ServerCertificate -> Bool)
-> Eq ServerCertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServerCertificate -> ServerCertificate -> Bool
$c/= :: ServerCertificate -> ServerCertificate -> Bool
== :: ServerCertificate -> ServerCertificate -> Bool
$c== :: ServerCertificate -> ServerCertificate -> Bool
Prelude.Eq, ReadPrec [ServerCertificate]
ReadPrec ServerCertificate
Int -> ReadS ServerCertificate
ReadS [ServerCertificate]
(Int -> ReadS ServerCertificate)
-> ReadS [ServerCertificate]
-> ReadPrec ServerCertificate
-> ReadPrec [ServerCertificate]
-> Read ServerCertificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServerCertificate]
$creadListPrec :: ReadPrec [ServerCertificate]
readPrec :: ReadPrec ServerCertificate
$creadPrec :: ReadPrec ServerCertificate
readList :: ReadS [ServerCertificate]
$creadList :: ReadS [ServerCertificate]
readsPrec :: Int -> ReadS ServerCertificate
$creadsPrec :: Int -> ReadS ServerCertificate
Prelude.Read, Int -> ServerCertificate -> ShowS
[ServerCertificate] -> ShowS
ServerCertificate -> String
(Int -> ServerCertificate -> ShowS)
-> (ServerCertificate -> String)
-> ([ServerCertificate] -> ShowS)
-> Show ServerCertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServerCertificate] -> ShowS
$cshowList :: [ServerCertificate] -> ShowS
show :: ServerCertificate -> String
$cshow :: ServerCertificate -> String
showsPrec :: Int -> ServerCertificate -> ShowS
$cshowsPrec :: Int -> ServerCertificate -> ShowS
Prelude.Show, (forall x. ServerCertificate -> Rep ServerCertificate x)
-> (forall x. Rep ServerCertificate x -> ServerCertificate)
-> Generic ServerCertificate
forall x. Rep ServerCertificate x -> ServerCertificate
forall x. ServerCertificate -> Rep ServerCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ServerCertificate x -> ServerCertificate
$cfrom :: forall x. ServerCertificate -> Rep ServerCertificate x
Prelude.Generic)

-- |
-- Create a value of 'ServerCertificate' 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:
--
-- 'certificateChain', 'serverCertificate_certificateChain' - The contents of the public key certificate chain.
--
-- 'tags', 'serverCertificate_tags' - A list of tags that are attached to the server certificate. For more
-- information about tagging, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
-- in the /IAM User Guide/.
--
-- 'serverCertificateMetadata', 'serverCertificate_serverCertificateMetadata' - The meta information of the server certificate, such as its name, path,
-- ID, and ARN.
--
-- 'certificateBody', 'serverCertificate_certificateBody' - The contents of the public key certificate.
newServerCertificate ::
  -- | 'serverCertificateMetadata'
  ServerCertificateMetadata ->
  -- | 'certificateBody'
  Prelude.Text ->
  ServerCertificate
newServerCertificate :: ServerCertificateMetadata -> Text -> ServerCertificate
newServerCertificate
  ServerCertificateMetadata
pServerCertificateMetadata_
  Text
pCertificateBody_ =
    ServerCertificate' :: Maybe Text
-> Maybe [Tag]
-> ServerCertificateMetadata
-> Text
-> ServerCertificate
ServerCertificate'
      { $sel:certificateChain:ServerCertificate' :: Maybe Text
certificateChain =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:ServerCertificate' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
        $sel:serverCertificateMetadata:ServerCertificate' :: ServerCertificateMetadata
serverCertificateMetadata =
          ServerCertificateMetadata
pServerCertificateMetadata_,
        $sel:certificateBody:ServerCertificate' :: Text
certificateBody = Text
pCertificateBody_
      }

-- | The contents of the public key certificate chain.
serverCertificate_certificateChain :: Lens.Lens' ServerCertificate (Prelude.Maybe Prelude.Text)
serverCertificate_certificateChain :: (Maybe Text -> f (Maybe Text))
-> ServerCertificate -> f ServerCertificate
serverCertificate_certificateChain = (ServerCertificate -> Maybe Text)
-> (ServerCertificate -> Maybe Text -> ServerCertificate)
-> Lens
     ServerCertificate ServerCertificate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerCertificate' {Maybe Text
certificateChain :: Maybe Text
$sel:certificateChain:ServerCertificate' :: ServerCertificate -> Maybe Text
certificateChain} -> Maybe Text
certificateChain) (\s :: ServerCertificate
s@ServerCertificate' {} Maybe Text
a -> ServerCertificate
s {$sel:certificateChain:ServerCertificate' :: Maybe Text
certificateChain = Maybe Text
a} :: ServerCertificate)

-- | A list of tags that are attached to the server certificate. For more
-- information about tagging, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
-- in the /IAM User Guide/.
serverCertificate_tags :: Lens.Lens' ServerCertificate (Prelude.Maybe [Tag])
serverCertificate_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> ServerCertificate -> f ServerCertificate
serverCertificate_tags = (ServerCertificate -> Maybe [Tag])
-> (ServerCertificate -> Maybe [Tag] -> ServerCertificate)
-> Lens
     ServerCertificate ServerCertificate (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerCertificate' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:ServerCertificate' :: ServerCertificate -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: ServerCertificate
s@ServerCertificate' {} Maybe [Tag]
a -> ServerCertificate
s {$sel:tags:ServerCertificate' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: ServerCertificate) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> ServerCertificate -> f ServerCertificate)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> ServerCertificate
-> f ServerCertificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The meta information of the server certificate, such as its name, path,
-- ID, and ARN.
serverCertificate_serverCertificateMetadata :: Lens.Lens' ServerCertificate ServerCertificateMetadata
serverCertificate_serverCertificateMetadata :: (ServerCertificateMetadata -> f ServerCertificateMetadata)
-> ServerCertificate -> f ServerCertificate
serverCertificate_serverCertificateMetadata = (ServerCertificate -> ServerCertificateMetadata)
-> (ServerCertificate
    -> ServerCertificateMetadata -> ServerCertificate)
-> Lens
     ServerCertificate
     ServerCertificate
     ServerCertificateMetadata
     ServerCertificateMetadata
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerCertificate' {ServerCertificateMetadata
serverCertificateMetadata :: ServerCertificateMetadata
$sel:serverCertificateMetadata:ServerCertificate' :: ServerCertificate -> ServerCertificateMetadata
serverCertificateMetadata} -> ServerCertificateMetadata
serverCertificateMetadata) (\s :: ServerCertificate
s@ServerCertificate' {} ServerCertificateMetadata
a -> ServerCertificate
s {$sel:serverCertificateMetadata:ServerCertificate' :: ServerCertificateMetadata
serverCertificateMetadata = ServerCertificateMetadata
a} :: ServerCertificate)

-- | The contents of the public key certificate.
serverCertificate_certificateBody :: Lens.Lens' ServerCertificate Prelude.Text
serverCertificate_certificateBody :: (Text -> f Text) -> ServerCertificate -> f ServerCertificate
serverCertificate_certificateBody = (ServerCertificate -> Text)
-> (ServerCertificate -> Text -> ServerCertificate)
-> Lens ServerCertificate ServerCertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerCertificate' {Text
certificateBody :: Text
$sel:certificateBody:ServerCertificate' :: ServerCertificate -> Text
certificateBody} -> Text
certificateBody) (\s :: ServerCertificate
s@ServerCertificate' {} Text
a -> ServerCertificate
s {$sel:certificateBody:ServerCertificate' :: Text
certificateBody = Text
a} :: ServerCertificate)

instance Core.FromXML ServerCertificate where
  parseXML :: [Node] -> Either String ServerCertificate
parseXML [Node]
x =
    Maybe Text
-> Maybe [Tag]
-> ServerCertificateMetadata
-> Text
-> ServerCertificate
ServerCertificate'
      (Maybe Text
 -> Maybe [Tag]
 -> ServerCertificateMetadata
 -> Text
 -> ServerCertificate)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [Tag]
      -> ServerCertificateMetadata -> Text -> ServerCertificate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CertificateChain")
      Either
  String
  (Maybe [Tag]
   -> ServerCertificateMetadata -> Text -> ServerCertificate)
-> Either String (Maybe [Tag])
-> Either
     String (ServerCertificateMetadata -> Text -> ServerCertificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Tags" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Tag]))
-> Either String (Maybe [Tag])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Tag])
-> [Node] -> Either String (Maybe [Tag])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Tag]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either
  String (ServerCertificateMetadata -> Text -> ServerCertificate)
-> Either String ServerCertificateMetadata
-> Either String (Text -> ServerCertificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String ServerCertificateMetadata
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ServerCertificateMetadata")
      Either String (Text -> ServerCertificate)
-> Either String Text -> Either String ServerCertificate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"CertificateBody")

instance Prelude.Hashable ServerCertificate

instance Prelude.NFData ServerCertificate