{-# 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.GameLift.Types.CertificateConfiguration
-- 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.GameLift.Types.CertificateConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.GameLift.Types.CertificateType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Determines whether a TLS\/SSL certificate is generated for a fleet. This
-- feature must be enabled when creating the fleet. All instances in a
-- fleet share the same certificate. The certificate can be retrieved by
-- calling the
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-serversdk.html GameLift Server SDK>
-- operation @GetInstanceCertificate@.
--
-- A fleet\'s certificate configuration is part of FleetAttributes.
--
-- /See:/ 'newCertificateConfiguration' smart constructor.
data CertificateConfiguration = CertificateConfiguration'
  { -- | Indicates whether a TLS\/SSL certificate is generated for a fleet.
    --
    -- Valid values include:
    --
    -- -   __GENERATED__ - Generate a TLS\/SSL certificate for this fleet.
    --
    -- -   __DISABLED__ - (default) Do not generate a TLS\/SSL certificate for
    --     this fleet.
    CertificateConfiguration -> CertificateType
certificateType :: CertificateType
  }
  deriving (CertificateConfiguration -> CertificateConfiguration -> Bool
(CertificateConfiguration -> CertificateConfiguration -> Bool)
-> (CertificateConfiguration -> CertificateConfiguration -> Bool)
-> Eq CertificateConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CertificateConfiguration -> CertificateConfiguration -> Bool
$c/= :: CertificateConfiguration -> CertificateConfiguration -> Bool
== :: CertificateConfiguration -> CertificateConfiguration -> Bool
$c== :: CertificateConfiguration -> CertificateConfiguration -> Bool
Prelude.Eq, ReadPrec [CertificateConfiguration]
ReadPrec CertificateConfiguration
Int -> ReadS CertificateConfiguration
ReadS [CertificateConfiguration]
(Int -> ReadS CertificateConfiguration)
-> ReadS [CertificateConfiguration]
-> ReadPrec CertificateConfiguration
-> ReadPrec [CertificateConfiguration]
-> Read CertificateConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CertificateConfiguration]
$creadListPrec :: ReadPrec [CertificateConfiguration]
readPrec :: ReadPrec CertificateConfiguration
$creadPrec :: ReadPrec CertificateConfiguration
readList :: ReadS [CertificateConfiguration]
$creadList :: ReadS [CertificateConfiguration]
readsPrec :: Int -> ReadS CertificateConfiguration
$creadsPrec :: Int -> ReadS CertificateConfiguration
Prelude.Read, Int -> CertificateConfiguration -> ShowS
[CertificateConfiguration] -> ShowS
CertificateConfiguration -> String
(Int -> CertificateConfiguration -> ShowS)
-> (CertificateConfiguration -> String)
-> ([CertificateConfiguration] -> ShowS)
-> Show CertificateConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CertificateConfiguration] -> ShowS
$cshowList :: [CertificateConfiguration] -> ShowS
show :: CertificateConfiguration -> String
$cshow :: CertificateConfiguration -> String
showsPrec :: Int -> CertificateConfiguration -> ShowS
$cshowsPrec :: Int -> CertificateConfiguration -> ShowS
Prelude.Show, (forall x.
 CertificateConfiguration -> Rep CertificateConfiguration x)
-> (forall x.
    Rep CertificateConfiguration x -> CertificateConfiguration)
-> Generic CertificateConfiguration
forall x.
Rep CertificateConfiguration x -> CertificateConfiguration
forall x.
CertificateConfiguration -> Rep CertificateConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CertificateConfiguration x -> CertificateConfiguration
$cfrom :: forall x.
CertificateConfiguration -> Rep CertificateConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'CertificateConfiguration' 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:
--
-- 'certificateType', 'certificateConfiguration_certificateType' - Indicates whether a TLS\/SSL certificate is generated for a fleet.
--
-- Valid values include:
--
-- -   __GENERATED__ - Generate a TLS\/SSL certificate for this fleet.
--
-- -   __DISABLED__ - (default) Do not generate a TLS\/SSL certificate for
--     this fleet.
newCertificateConfiguration ::
  -- | 'certificateType'
  CertificateType ->
  CertificateConfiguration
newCertificateConfiguration :: CertificateType -> CertificateConfiguration
newCertificateConfiguration CertificateType
pCertificateType_ =
  CertificateConfiguration' :: CertificateType -> CertificateConfiguration
CertificateConfiguration'
    { $sel:certificateType:CertificateConfiguration' :: CertificateType
certificateType =
        CertificateType
pCertificateType_
    }

-- | Indicates whether a TLS\/SSL certificate is generated for a fleet.
--
-- Valid values include:
--
-- -   __GENERATED__ - Generate a TLS\/SSL certificate for this fleet.
--
-- -   __DISABLED__ - (default) Do not generate a TLS\/SSL certificate for
--     this fleet.
certificateConfiguration_certificateType :: Lens.Lens' CertificateConfiguration CertificateType
certificateConfiguration_certificateType :: (CertificateType -> f CertificateType)
-> CertificateConfiguration -> f CertificateConfiguration
certificateConfiguration_certificateType = (CertificateConfiguration -> CertificateType)
-> (CertificateConfiguration
    -> CertificateType -> CertificateConfiguration)
-> Lens
     CertificateConfiguration
     CertificateConfiguration
     CertificateType
     CertificateType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CertificateConfiguration' {CertificateType
certificateType :: CertificateType
$sel:certificateType:CertificateConfiguration' :: CertificateConfiguration -> CertificateType
certificateType} -> CertificateType
certificateType) (\s :: CertificateConfiguration
s@CertificateConfiguration' {} CertificateType
a -> CertificateConfiguration
s {$sel:certificateType:CertificateConfiguration' :: CertificateType
certificateType = CertificateType
a} :: CertificateConfiguration)

instance Core.FromJSON CertificateConfiguration where
  parseJSON :: Value -> Parser CertificateConfiguration
parseJSON =
    String
-> (Object -> Parser CertificateConfiguration)
-> Value
-> Parser CertificateConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CertificateConfiguration"
      ( \Object
x ->
          CertificateType -> CertificateConfiguration
CertificateConfiguration'
            (CertificateType -> CertificateConfiguration)
-> Parser CertificateType -> Parser CertificateConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser CertificateType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"CertificateType")
      )

instance Prelude.Hashable CertificateConfiguration

instance Prelude.NFData CertificateConfiguration

instance Core.ToJSON CertificateConfiguration where
  toJSON :: CertificateConfiguration -> Value
toJSON CertificateConfiguration' {CertificateType
certificateType :: CertificateType
$sel:certificateType:CertificateConfiguration' :: CertificateConfiguration -> CertificateType
..} =
    [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
"CertificateType" Text -> CertificateType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CertificateType
certificateType)
          ]
      )