{-# 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.EKS.DescribeAddon
-- 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)
--
-- Describes an Amazon EKS add-on.
module Amazonka.EKS.DescribeAddon
  ( -- * Creating a Request
    DescribeAddon (..),
    newDescribeAddon,

    -- * Request Lenses
    describeAddon_clusterName,
    describeAddon_addonName,

    -- * Destructuring the Response
    DescribeAddonResponse (..),
    newDescribeAddonResponse,

    -- * Response Lenses
    describeAddonResponse_addon,
    describeAddonResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.EKS.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeAddon' smart constructor.
data DescribeAddon = DescribeAddon'
  { -- | The name of the cluster.
    DescribeAddon -> Text
clusterName :: Prelude.Text,
    -- | The name of the add-on. The name must match one of the names returned by
    -- <https://docs.aws.amazon.com/eks/latest/APIReference/API_ListAddons.html ListAddons>
    -- .
    DescribeAddon -> Text
addonName :: Prelude.Text
  }
  deriving (DescribeAddon -> DescribeAddon -> Bool
(DescribeAddon -> DescribeAddon -> Bool)
-> (DescribeAddon -> DescribeAddon -> Bool) -> Eq DescribeAddon
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAddon -> DescribeAddon -> Bool
$c/= :: DescribeAddon -> DescribeAddon -> Bool
== :: DescribeAddon -> DescribeAddon -> Bool
$c== :: DescribeAddon -> DescribeAddon -> Bool
Prelude.Eq, ReadPrec [DescribeAddon]
ReadPrec DescribeAddon
Int -> ReadS DescribeAddon
ReadS [DescribeAddon]
(Int -> ReadS DescribeAddon)
-> ReadS [DescribeAddon]
-> ReadPrec DescribeAddon
-> ReadPrec [DescribeAddon]
-> Read DescribeAddon
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAddon]
$creadListPrec :: ReadPrec [DescribeAddon]
readPrec :: ReadPrec DescribeAddon
$creadPrec :: ReadPrec DescribeAddon
readList :: ReadS [DescribeAddon]
$creadList :: ReadS [DescribeAddon]
readsPrec :: Int -> ReadS DescribeAddon
$creadsPrec :: Int -> ReadS DescribeAddon
Prelude.Read, Int -> DescribeAddon -> ShowS
[DescribeAddon] -> ShowS
DescribeAddon -> String
(Int -> DescribeAddon -> ShowS)
-> (DescribeAddon -> String)
-> ([DescribeAddon] -> ShowS)
-> Show DescribeAddon
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAddon] -> ShowS
$cshowList :: [DescribeAddon] -> ShowS
show :: DescribeAddon -> String
$cshow :: DescribeAddon -> String
showsPrec :: Int -> DescribeAddon -> ShowS
$cshowsPrec :: Int -> DescribeAddon -> ShowS
Prelude.Show, (forall x. DescribeAddon -> Rep DescribeAddon x)
-> (forall x. Rep DescribeAddon x -> DescribeAddon)
-> Generic DescribeAddon
forall x. Rep DescribeAddon x -> DescribeAddon
forall x. DescribeAddon -> Rep DescribeAddon x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAddon x -> DescribeAddon
$cfrom :: forall x. DescribeAddon -> Rep DescribeAddon x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAddon' 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:
--
-- 'clusterName', 'describeAddon_clusterName' - The name of the cluster.
--
-- 'addonName', 'describeAddon_addonName' - The name of the add-on. The name must match one of the names returned by
-- <https://docs.aws.amazon.com/eks/latest/APIReference/API_ListAddons.html ListAddons>
-- .
newDescribeAddon ::
  -- | 'clusterName'
  Prelude.Text ->
  -- | 'addonName'
  Prelude.Text ->
  DescribeAddon
newDescribeAddon :: Text -> Text -> DescribeAddon
newDescribeAddon Text
pClusterName_ Text
pAddonName_ =
  DescribeAddon' :: Text -> Text -> DescribeAddon
DescribeAddon'
    { $sel:clusterName:DescribeAddon' :: Text
clusterName = Text
pClusterName_,
      $sel:addonName:DescribeAddon' :: Text
addonName = Text
pAddonName_
    }

-- | The name of the cluster.
describeAddon_clusterName :: Lens.Lens' DescribeAddon Prelude.Text
describeAddon_clusterName :: (Text -> f Text) -> DescribeAddon -> f DescribeAddon
describeAddon_clusterName = (DescribeAddon -> Text)
-> (DescribeAddon -> Text -> DescribeAddon)
-> Lens DescribeAddon DescribeAddon Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAddon' {Text
clusterName :: Text
$sel:clusterName:DescribeAddon' :: DescribeAddon -> Text
clusterName} -> Text
clusterName) (\s :: DescribeAddon
s@DescribeAddon' {} Text
a -> DescribeAddon
s {$sel:clusterName:DescribeAddon' :: Text
clusterName = Text
a} :: DescribeAddon)

-- | The name of the add-on. The name must match one of the names returned by
-- <https://docs.aws.amazon.com/eks/latest/APIReference/API_ListAddons.html ListAddons>
-- .
describeAddon_addonName :: Lens.Lens' DescribeAddon Prelude.Text
describeAddon_addonName :: (Text -> f Text) -> DescribeAddon -> f DescribeAddon
describeAddon_addonName = (DescribeAddon -> Text)
-> (DescribeAddon -> Text -> DescribeAddon)
-> Lens DescribeAddon DescribeAddon Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAddon' {Text
addonName :: Text
$sel:addonName:DescribeAddon' :: DescribeAddon -> Text
addonName} -> Text
addonName) (\s :: DescribeAddon
s@DescribeAddon' {} Text
a -> DescribeAddon
s {$sel:addonName:DescribeAddon' :: Text
addonName = Text
a} :: DescribeAddon)

instance Core.AWSRequest DescribeAddon where
  type
    AWSResponse DescribeAddon =
      DescribeAddonResponse
  request :: DescribeAddon -> Request DescribeAddon
request = Service -> DescribeAddon -> Request DescribeAddon
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeAddon
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeAddon)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeAddon))
-> Logger
-> Service
-> Proxy DescribeAddon
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeAddon)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Addon -> Int -> DescribeAddonResponse
DescribeAddonResponse'
            (Maybe Addon -> Int -> DescribeAddonResponse)
-> Either String (Maybe Addon)
-> Either String (Int -> DescribeAddonResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Addon)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"addon")
            Either String (Int -> DescribeAddonResponse)
-> Either String Int -> Either String DescribeAddonResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeAddon

instance Prelude.NFData DescribeAddon

instance Core.ToHeaders DescribeAddon where
  toHeaders :: DescribeAddon -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeAddon -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath DescribeAddon where
  toPath :: DescribeAddon -> ByteString
toPath DescribeAddon' {Text
addonName :: Text
clusterName :: Text
$sel:addonName:DescribeAddon' :: DescribeAddon -> Text
$sel:clusterName:DescribeAddon' :: DescribeAddon -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/clusters/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
clusterName,
        ByteString
"/addons/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
addonName
      ]

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

-- | /See:/ 'newDescribeAddonResponse' smart constructor.
data DescribeAddonResponse = DescribeAddonResponse'
  { DescribeAddonResponse -> Maybe Addon
addon :: Prelude.Maybe Addon,
    -- | The response's http status code.
    DescribeAddonResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAddonResponse -> DescribeAddonResponse -> Bool
(DescribeAddonResponse -> DescribeAddonResponse -> Bool)
-> (DescribeAddonResponse -> DescribeAddonResponse -> Bool)
-> Eq DescribeAddonResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAddonResponse -> DescribeAddonResponse -> Bool
$c/= :: DescribeAddonResponse -> DescribeAddonResponse -> Bool
== :: DescribeAddonResponse -> DescribeAddonResponse -> Bool
$c== :: DescribeAddonResponse -> DescribeAddonResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAddonResponse]
ReadPrec DescribeAddonResponse
Int -> ReadS DescribeAddonResponse
ReadS [DescribeAddonResponse]
(Int -> ReadS DescribeAddonResponse)
-> ReadS [DescribeAddonResponse]
-> ReadPrec DescribeAddonResponse
-> ReadPrec [DescribeAddonResponse]
-> Read DescribeAddonResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAddonResponse]
$creadListPrec :: ReadPrec [DescribeAddonResponse]
readPrec :: ReadPrec DescribeAddonResponse
$creadPrec :: ReadPrec DescribeAddonResponse
readList :: ReadS [DescribeAddonResponse]
$creadList :: ReadS [DescribeAddonResponse]
readsPrec :: Int -> ReadS DescribeAddonResponse
$creadsPrec :: Int -> ReadS DescribeAddonResponse
Prelude.Read, Int -> DescribeAddonResponse -> ShowS
[DescribeAddonResponse] -> ShowS
DescribeAddonResponse -> String
(Int -> DescribeAddonResponse -> ShowS)
-> (DescribeAddonResponse -> String)
-> ([DescribeAddonResponse] -> ShowS)
-> Show DescribeAddonResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAddonResponse] -> ShowS
$cshowList :: [DescribeAddonResponse] -> ShowS
show :: DescribeAddonResponse -> String
$cshow :: DescribeAddonResponse -> String
showsPrec :: Int -> DescribeAddonResponse -> ShowS
$cshowsPrec :: Int -> DescribeAddonResponse -> ShowS
Prelude.Show, (forall x. DescribeAddonResponse -> Rep DescribeAddonResponse x)
-> (forall x. Rep DescribeAddonResponse x -> DescribeAddonResponse)
-> Generic DescribeAddonResponse
forall x. Rep DescribeAddonResponse x -> DescribeAddonResponse
forall x. DescribeAddonResponse -> Rep DescribeAddonResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAddonResponse x -> DescribeAddonResponse
$cfrom :: forall x. DescribeAddonResponse -> Rep DescribeAddonResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAddonResponse' 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:
--
-- 'addon', 'describeAddonResponse_addon' - Undocumented member.
--
-- 'httpStatus', 'describeAddonResponse_httpStatus' - The response's http status code.
newDescribeAddonResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAddonResponse
newDescribeAddonResponse :: Int -> DescribeAddonResponse
newDescribeAddonResponse Int
pHttpStatus_ =
  DescribeAddonResponse' :: Maybe Addon -> Int -> DescribeAddonResponse
DescribeAddonResponse'
    { $sel:addon:DescribeAddonResponse' :: Maybe Addon
addon = Maybe Addon
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAddonResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
describeAddonResponse_addon :: Lens.Lens' DescribeAddonResponse (Prelude.Maybe Addon)
describeAddonResponse_addon :: (Maybe Addon -> f (Maybe Addon))
-> DescribeAddonResponse -> f DescribeAddonResponse
describeAddonResponse_addon = (DescribeAddonResponse -> Maybe Addon)
-> (DescribeAddonResponse -> Maybe Addon -> DescribeAddonResponse)
-> Lens
     DescribeAddonResponse
     DescribeAddonResponse
     (Maybe Addon)
     (Maybe Addon)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAddonResponse' {Maybe Addon
addon :: Maybe Addon
$sel:addon:DescribeAddonResponse' :: DescribeAddonResponse -> Maybe Addon
addon} -> Maybe Addon
addon) (\s :: DescribeAddonResponse
s@DescribeAddonResponse' {} Maybe Addon
a -> DescribeAddonResponse
s {$sel:addon:DescribeAddonResponse' :: Maybe Addon
addon = Maybe Addon
a} :: DescribeAddonResponse)

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

instance Prelude.NFData DescribeAddonResponse