{-# 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.ELBV2.Types.Certificate
-- 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.ELBV2.Types.Certificate where

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

-- | Information about an SSL server certificate.
--
-- /See:/ 'newCertificate' smart constructor.
data Certificate = Certificate'
  { -- | The Amazon Resource Name (ARN) of the certificate.
    Certificate -> Maybe Text
certificateArn :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether the certificate is the default certificate. Do not set
    -- this value when specifying a certificate as an input. This value is not
    -- included in the output when describing a listener, but is included when
    -- describing listener certificates.
    Certificate -> Maybe Bool
isDefault :: Prelude.Maybe Prelude.Bool
  }
  deriving (Certificate -> Certificate -> Bool
(Certificate -> Certificate -> Bool)
-> (Certificate -> Certificate -> Bool) -> Eq Certificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Certificate -> Certificate -> Bool
$c/= :: Certificate -> Certificate -> Bool
== :: Certificate -> Certificate -> Bool
$c== :: Certificate -> Certificate -> Bool
Prelude.Eq, ReadPrec [Certificate]
ReadPrec Certificate
Int -> ReadS Certificate
ReadS [Certificate]
(Int -> ReadS Certificate)
-> ReadS [Certificate]
-> ReadPrec Certificate
-> ReadPrec [Certificate]
-> Read Certificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Certificate]
$creadListPrec :: ReadPrec [Certificate]
readPrec :: ReadPrec Certificate
$creadPrec :: ReadPrec Certificate
readList :: ReadS [Certificate]
$creadList :: ReadS [Certificate]
readsPrec :: Int -> ReadS Certificate
$creadsPrec :: Int -> ReadS Certificate
Prelude.Read, Int -> Certificate -> ShowS
[Certificate] -> ShowS
Certificate -> String
(Int -> Certificate -> ShowS)
-> (Certificate -> String)
-> ([Certificate] -> ShowS)
-> Show Certificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Certificate] -> ShowS
$cshowList :: [Certificate] -> ShowS
show :: Certificate -> String
$cshow :: Certificate -> String
showsPrec :: Int -> Certificate -> ShowS
$cshowsPrec :: Int -> Certificate -> ShowS
Prelude.Show, (forall x. Certificate -> Rep Certificate x)
-> (forall x. Rep Certificate x -> Certificate)
-> Generic Certificate
forall x. Rep Certificate x -> Certificate
forall x. Certificate -> Rep Certificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Certificate x -> Certificate
$cfrom :: forall x. Certificate -> Rep Certificate x
Prelude.Generic)

-- |
-- Create a value of 'Certificate' 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:
--
-- 'certificateArn', 'certificate_certificateArn' - The Amazon Resource Name (ARN) of the certificate.
--
-- 'isDefault', 'certificate_isDefault' - Indicates whether the certificate is the default certificate. Do not set
-- this value when specifying a certificate as an input. This value is not
-- included in the output when describing a listener, but is included when
-- describing listener certificates.
newCertificate ::
  Certificate
newCertificate :: Certificate
newCertificate =
  Certificate' :: Maybe Text -> Maybe Bool -> Certificate
Certificate'
    { $sel:certificateArn:Certificate' :: Maybe Text
certificateArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:isDefault:Certificate' :: Maybe Bool
isDefault = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the certificate.
certificate_certificateArn :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_certificateArn :: (Maybe Text -> f (Maybe Text)) -> Certificate -> f Certificate
certificate_certificateArn = (Certificate -> Maybe Text)
-> (Certificate -> Maybe Text -> Certificate)
-> Lens Certificate Certificate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe Text
certificateArn :: Maybe Text
$sel:certificateArn:Certificate' :: Certificate -> Maybe Text
certificateArn} -> Maybe Text
certificateArn) (\s :: Certificate
s@Certificate' {} Maybe Text
a -> Certificate
s {$sel:certificateArn:Certificate' :: Maybe Text
certificateArn = Maybe Text
a} :: Certificate)

-- | Indicates whether the certificate is the default certificate. Do not set
-- this value when specifying a certificate as an input. This value is not
-- included in the output when describing a listener, but is included when
-- describing listener certificates.
certificate_isDefault :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Bool)
certificate_isDefault :: (Maybe Bool -> f (Maybe Bool)) -> Certificate -> f Certificate
certificate_isDefault = (Certificate -> Maybe Bool)
-> (Certificate -> Maybe Bool -> Certificate)
-> Lens Certificate Certificate (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe Bool
isDefault :: Maybe Bool
$sel:isDefault:Certificate' :: Certificate -> Maybe Bool
isDefault} -> Maybe Bool
isDefault) (\s :: Certificate
s@Certificate' {} Maybe Bool
a -> Certificate
s {$sel:isDefault:Certificate' :: Maybe Bool
isDefault = Maybe Bool
a} :: Certificate)

instance Core.FromXML Certificate where
  parseXML :: [Node] -> Either String Certificate
parseXML [Node]
x =
    Maybe Text -> Maybe Bool -> Certificate
Certificate'
      (Maybe Text -> Maybe Bool -> Certificate)
-> Either String (Maybe Text)
-> Either String (Maybe Bool -> Certificate)
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
"CertificateArn")
      Either String (Maybe Bool -> Certificate)
-> Either String (Maybe Bool) -> Either String Certificate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"IsDefault")

instance Prelude.Hashable Certificate

instance Prelude.NFData Certificate

instance Core.ToQuery Certificate where
  toQuery :: Certificate -> QueryString
toQuery Certificate' {Maybe Bool
Maybe Text
isDefault :: Maybe Bool
certificateArn :: Maybe Text
$sel:isDefault:Certificate' :: Certificate -> Maybe Bool
$sel:certificateArn:Certificate' :: Certificate -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"CertificateArn" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
certificateArn,
        ByteString
"IsDefault" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
isDefault
      ]