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

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

-- |
-- Module      : Amazonka.CloudFront.GetKeyGroupConfig
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets a key group configuration.
--
-- To get a key group configuration, you must provide the key group\'s
-- identifier. If the key group is referenced in a distribution\'s cache
-- behavior, you can get the key group\'s identifier using
-- @ListDistributions@ or @GetDistribution@. If the key group is not
-- referenced in a cache behavior, you can get the identifier using
-- @ListKeyGroups@.
module Amazonka.CloudFront.GetKeyGroupConfig
  ( -- * Creating a Request
    GetKeyGroupConfig (..),
    newGetKeyGroupConfig,

    -- * Request Lenses
    getKeyGroupConfig_id,

    -- * Destructuring the Response
    GetKeyGroupConfigResponse (..),
    newGetKeyGroupConfigResponse,

    -- * Response Lenses
    getKeyGroupConfigResponse_eTag,
    getKeyGroupConfigResponse_keyGroupConfig,
    getKeyGroupConfigResponse_httpStatus,
  )
where

import Amazonka.CloudFront.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetKeyGroupConfig' smart constructor.
data GetKeyGroupConfig = GetKeyGroupConfig'
  { -- | The identifier of the key group whose configuration you are getting. To
    -- get the identifier, use @ListKeyGroups@.
    GetKeyGroupConfig -> Text
id :: Prelude.Text
  }
  deriving (GetKeyGroupConfig -> GetKeyGroupConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetKeyGroupConfig -> GetKeyGroupConfig -> Bool
$c/= :: GetKeyGroupConfig -> GetKeyGroupConfig -> Bool
== :: GetKeyGroupConfig -> GetKeyGroupConfig -> Bool
$c== :: GetKeyGroupConfig -> GetKeyGroupConfig -> Bool
Prelude.Eq, ReadPrec [GetKeyGroupConfig]
ReadPrec GetKeyGroupConfig
Int -> ReadS GetKeyGroupConfig
ReadS [GetKeyGroupConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetKeyGroupConfig]
$creadListPrec :: ReadPrec [GetKeyGroupConfig]
readPrec :: ReadPrec GetKeyGroupConfig
$creadPrec :: ReadPrec GetKeyGroupConfig
readList :: ReadS [GetKeyGroupConfig]
$creadList :: ReadS [GetKeyGroupConfig]
readsPrec :: Int -> ReadS GetKeyGroupConfig
$creadsPrec :: Int -> ReadS GetKeyGroupConfig
Prelude.Read, Int -> GetKeyGroupConfig -> ShowS
[GetKeyGroupConfig] -> ShowS
GetKeyGroupConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetKeyGroupConfig] -> ShowS
$cshowList :: [GetKeyGroupConfig] -> ShowS
show :: GetKeyGroupConfig -> String
$cshow :: GetKeyGroupConfig -> String
showsPrec :: Int -> GetKeyGroupConfig -> ShowS
$cshowsPrec :: Int -> GetKeyGroupConfig -> ShowS
Prelude.Show, forall x. Rep GetKeyGroupConfig x -> GetKeyGroupConfig
forall x. GetKeyGroupConfig -> Rep GetKeyGroupConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetKeyGroupConfig x -> GetKeyGroupConfig
$cfrom :: forall x. GetKeyGroupConfig -> Rep GetKeyGroupConfig x
Prelude.Generic)

-- |
-- Create a value of 'GetKeyGroupConfig' 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:
--
-- 'id', 'getKeyGroupConfig_id' - The identifier of the key group whose configuration you are getting. To
-- get the identifier, use @ListKeyGroups@.
newGetKeyGroupConfig ::
  -- | 'id'
  Prelude.Text ->
  GetKeyGroupConfig
newGetKeyGroupConfig :: Text -> GetKeyGroupConfig
newGetKeyGroupConfig Text
pId_ =
  GetKeyGroupConfig' {$sel:id:GetKeyGroupConfig' :: Text
id = Text
pId_}

-- | The identifier of the key group whose configuration you are getting. To
-- get the identifier, use @ListKeyGroups@.
getKeyGroupConfig_id :: Lens.Lens' GetKeyGroupConfig Prelude.Text
getKeyGroupConfig_id :: Lens' GetKeyGroupConfig Text
getKeyGroupConfig_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetKeyGroupConfig' {Text
id :: Text
$sel:id:GetKeyGroupConfig' :: GetKeyGroupConfig -> Text
id} -> Text
id) (\s :: GetKeyGroupConfig
s@GetKeyGroupConfig' {} Text
a -> GetKeyGroupConfig
s {$sel:id:GetKeyGroupConfig' :: Text
id = Text
a} :: GetKeyGroupConfig)

instance Core.AWSRequest GetKeyGroupConfig where
  type
    AWSResponse GetKeyGroupConfig =
      GetKeyGroupConfigResponse
  request :: (Service -> Service)
-> GetKeyGroupConfig -> Request GetKeyGroupConfig
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetKeyGroupConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetKeyGroupConfig)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text
-> Maybe KeyGroupConfig -> Int -> GetKeyGroupConfigResponse
GetKeyGroupConfigResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Data..#? HeaderName
"ETag")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall a. FromXML a => [Node] -> Either String a
Data.parseXML [Node]
x)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetKeyGroupConfig where
  hashWithSalt :: Int -> GetKeyGroupConfig -> Int
hashWithSalt Int
_salt GetKeyGroupConfig' {Text
id :: Text
$sel:id:GetKeyGroupConfig' :: GetKeyGroupConfig -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData GetKeyGroupConfig where
  rnf :: GetKeyGroupConfig -> ()
rnf GetKeyGroupConfig' {Text
id :: Text
$sel:id:GetKeyGroupConfig' :: GetKeyGroupConfig -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
id

instance Data.ToHeaders GetKeyGroupConfig where
  toHeaders :: GetKeyGroupConfig -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath GetKeyGroupConfig where
  toPath :: GetKeyGroupConfig -> ByteString
toPath GetKeyGroupConfig' {Text
id :: Text
$sel:id:GetKeyGroupConfig' :: GetKeyGroupConfig -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2020-05-31/key-group/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id, ByteString
"/config"]

instance Data.ToQuery GetKeyGroupConfig where
  toQuery :: GetKeyGroupConfig -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetKeyGroupConfigResponse' smart constructor.
data GetKeyGroupConfigResponse = GetKeyGroupConfigResponse'
  { -- | The identifier for this version of the key group.
    GetKeyGroupConfigResponse -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
    -- | The key group configuration.
    GetKeyGroupConfigResponse -> Maybe KeyGroupConfig
keyGroupConfig :: Prelude.Maybe KeyGroupConfig,
    -- | The response's http status code.
    GetKeyGroupConfigResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetKeyGroupConfigResponse -> GetKeyGroupConfigResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetKeyGroupConfigResponse -> GetKeyGroupConfigResponse -> Bool
$c/= :: GetKeyGroupConfigResponse -> GetKeyGroupConfigResponse -> Bool
== :: GetKeyGroupConfigResponse -> GetKeyGroupConfigResponse -> Bool
$c== :: GetKeyGroupConfigResponse -> GetKeyGroupConfigResponse -> Bool
Prelude.Eq, ReadPrec [GetKeyGroupConfigResponse]
ReadPrec GetKeyGroupConfigResponse
Int -> ReadS GetKeyGroupConfigResponse
ReadS [GetKeyGroupConfigResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetKeyGroupConfigResponse]
$creadListPrec :: ReadPrec [GetKeyGroupConfigResponse]
readPrec :: ReadPrec GetKeyGroupConfigResponse
$creadPrec :: ReadPrec GetKeyGroupConfigResponse
readList :: ReadS [GetKeyGroupConfigResponse]
$creadList :: ReadS [GetKeyGroupConfigResponse]
readsPrec :: Int -> ReadS GetKeyGroupConfigResponse
$creadsPrec :: Int -> ReadS GetKeyGroupConfigResponse
Prelude.Read, Int -> GetKeyGroupConfigResponse -> ShowS
[GetKeyGroupConfigResponse] -> ShowS
GetKeyGroupConfigResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetKeyGroupConfigResponse] -> ShowS
$cshowList :: [GetKeyGroupConfigResponse] -> ShowS
show :: GetKeyGroupConfigResponse -> String
$cshow :: GetKeyGroupConfigResponse -> String
showsPrec :: Int -> GetKeyGroupConfigResponse -> ShowS
$cshowsPrec :: Int -> GetKeyGroupConfigResponse -> ShowS
Prelude.Show, forall x.
Rep GetKeyGroupConfigResponse x -> GetKeyGroupConfigResponse
forall x.
GetKeyGroupConfigResponse -> Rep GetKeyGroupConfigResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetKeyGroupConfigResponse x -> GetKeyGroupConfigResponse
$cfrom :: forall x.
GetKeyGroupConfigResponse -> Rep GetKeyGroupConfigResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetKeyGroupConfigResponse' 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:
--
-- 'eTag', 'getKeyGroupConfigResponse_eTag' - The identifier for this version of the key group.
--
-- 'keyGroupConfig', 'getKeyGroupConfigResponse_keyGroupConfig' - The key group configuration.
--
-- 'httpStatus', 'getKeyGroupConfigResponse_httpStatus' - The response's http status code.
newGetKeyGroupConfigResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetKeyGroupConfigResponse
newGetKeyGroupConfigResponse :: Int -> GetKeyGroupConfigResponse
newGetKeyGroupConfigResponse Int
pHttpStatus_ =
  GetKeyGroupConfigResponse'
    { $sel:eTag:GetKeyGroupConfigResponse' :: Maybe Text
eTag = forall a. Maybe a
Prelude.Nothing,
      $sel:keyGroupConfig:GetKeyGroupConfigResponse' :: Maybe KeyGroupConfig
keyGroupConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetKeyGroupConfigResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The identifier for this version of the key group.
getKeyGroupConfigResponse_eTag :: Lens.Lens' GetKeyGroupConfigResponse (Prelude.Maybe Prelude.Text)
getKeyGroupConfigResponse_eTag :: Lens' GetKeyGroupConfigResponse (Maybe Text)
getKeyGroupConfigResponse_eTag = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetKeyGroupConfigResponse' {Maybe Text
eTag :: Maybe Text
$sel:eTag:GetKeyGroupConfigResponse' :: GetKeyGroupConfigResponse -> Maybe Text
eTag} -> Maybe Text
eTag) (\s :: GetKeyGroupConfigResponse
s@GetKeyGroupConfigResponse' {} Maybe Text
a -> GetKeyGroupConfigResponse
s {$sel:eTag:GetKeyGroupConfigResponse' :: Maybe Text
eTag = Maybe Text
a} :: GetKeyGroupConfigResponse)

-- | The key group configuration.
getKeyGroupConfigResponse_keyGroupConfig :: Lens.Lens' GetKeyGroupConfigResponse (Prelude.Maybe KeyGroupConfig)
getKeyGroupConfigResponse_keyGroupConfig :: Lens' GetKeyGroupConfigResponse (Maybe KeyGroupConfig)
getKeyGroupConfigResponse_keyGroupConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetKeyGroupConfigResponse' {Maybe KeyGroupConfig
keyGroupConfig :: Maybe KeyGroupConfig
$sel:keyGroupConfig:GetKeyGroupConfigResponse' :: GetKeyGroupConfigResponse -> Maybe KeyGroupConfig
keyGroupConfig} -> Maybe KeyGroupConfig
keyGroupConfig) (\s :: GetKeyGroupConfigResponse
s@GetKeyGroupConfigResponse' {} Maybe KeyGroupConfig
a -> GetKeyGroupConfigResponse
s {$sel:keyGroupConfig:GetKeyGroupConfigResponse' :: Maybe KeyGroupConfig
keyGroupConfig = Maybe KeyGroupConfig
a} :: GetKeyGroupConfigResponse)

-- | The response's http status code.
getKeyGroupConfigResponse_httpStatus :: Lens.Lens' GetKeyGroupConfigResponse Prelude.Int
getKeyGroupConfigResponse_httpStatus :: Lens' GetKeyGroupConfigResponse Int
getKeyGroupConfigResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetKeyGroupConfigResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetKeyGroupConfigResponse' :: GetKeyGroupConfigResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetKeyGroupConfigResponse
s@GetKeyGroupConfigResponse' {} Int
a -> GetKeyGroupConfigResponse
s {$sel:httpStatus:GetKeyGroupConfigResponse' :: Int
httpStatus = Int
a} :: GetKeyGroupConfigResponse)

instance Prelude.NFData GetKeyGroupConfigResponse where
  rnf :: GetKeyGroupConfigResponse -> ()
rnf GetKeyGroupConfigResponse' {Int
Maybe Text
Maybe KeyGroupConfig
httpStatus :: Int
keyGroupConfig :: Maybe KeyGroupConfig
eTag :: Maybe Text
$sel:httpStatus:GetKeyGroupConfigResponse' :: GetKeyGroupConfigResponse -> Int
$sel:keyGroupConfig:GetKeyGroupConfigResponse' :: GetKeyGroupConfigResponse -> Maybe KeyGroupConfig
$sel:eTag:GetKeyGroupConfigResponse' :: GetKeyGroupConfigResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eTag
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe KeyGroupConfig
keyGroupConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus