{-# 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.DeregisterCluster
-- 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)
--
-- Deregisters a connected cluster to remove it from the Amazon EKS control
-- plane.
module Amazonka.EKS.DeregisterCluster
  ( -- * Creating a Request
    DeregisterCluster (..),
    newDeregisterCluster,

    -- * Request Lenses
    deregisterCluster_name,

    -- * Destructuring the Response
    DeregisterClusterResponse (..),
    newDeregisterClusterResponse,

    -- * Response Lenses
    deregisterClusterResponse_cluster,
    deregisterClusterResponse_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:/ 'newDeregisterCluster' smart constructor.
data DeregisterCluster = DeregisterCluster'
  { -- | The name of the connected cluster to deregister.
    DeregisterCluster -> Text
name :: Prelude.Text
  }
  deriving (DeregisterCluster -> DeregisterCluster -> Bool
(DeregisterCluster -> DeregisterCluster -> Bool)
-> (DeregisterCluster -> DeregisterCluster -> Bool)
-> Eq DeregisterCluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterCluster -> DeregisterCluster -> Bool
$c/= :: DeregisterCluster -> DeregisterCluster -> Bool
== :: DeregisterCluster -> DeregisterCluster -> Bool
$c== :: DeregisterCluster -> DeregisterCluster -> Bool
Prelude.Eq, ReadPrec [DeregisterCluster]
ReadPrec DeregisterCluster
Int -> ReadS DeregisterCluster
ReadS [DeregisterCluster]
(Int -> ReadS DeregisterCluster)
-> ReadS [DeregisterCluster]
-> ReadPrec DeregisterCluster
-> ReadPrec [DeregisterCluster]
-> Read DeregisterCluster
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterCluster]
$creadListPrec :: ReadPrec [DeregisterCluster]
readPrec :: ReadPrec DeregisterCluster
$creadPrec :: ReadPrec DeregisterCluster
readList :: ReadS [DeregisterCluster]
$creadList :: ReadS [DeregisterCluster]
readsPrec :: Int -> ReadS DeregisterCluster
$creadsPrec :: Int -> ReadS DeregisterCluster
Prelude.Read, Int -> DeregisterCluster -> ShowS
[DeregisterCluster] -> ShowS
DeregisterCluster -> String
(Int -> DeregisterCluster -> ShowS)
-> (DeregisterCluster -> String)
-> ([DeregisterCluster] -> ShowS)
-> Show DeregisterCluster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterCluster] -> ShowS
$cshowList :: [DeregisterCluster] -> ShowS
show :: DeregisterCluster -> String
$cshow :: DeregisterCluster -> String
showsPrec :: Int -> DeregisterCluster -> ShowS
$cshowsPrec :: Int -> DeregisterCluster -> ShowS
Prelude.Show, (forall x. DeregisterCluster -> Rep DeregisterCluster x)
-> (forall x. Rep DeregisterCluster x -> DeregisterCluster)
-> Generic DeregisterCluster
forall x. Rep DeregisterCluster x -> DeregisterCluster
forall x. DeregisterCluster -> Rep DeregisterCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeregisterCluster x -> DeregisterCluster
$cfrom :: forall x. DeregisterCluster -> Rep DeregisterCluster x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterCluster' 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:
--
-- 'name', 'deregisterCluster_name' - The name of the connected cluster to deregister.
newDeregisterCluster ::
  -- | 'name'
  Prelude.Text ->
  DeregisterCluster
newDeregisterCluster :: Text -> DeregisterCluster
newDeregisterCluster Text
pName_ =
  DeregisterCluster' :: Text -> DeregisterCluster
DeregisterCluster' {$sel:name:DeregisterCluster' :: Text
name = Text
pName_}

-- | The name of the connected cluster to deregister.
deregisterCluster_name :: Lens.Lens' DeregisterCluster Prelude.Text
deregisterCluster_name :: (Text -> f Text) -> DeregisterCluster -> f DeregisterCluster
deregisterCluster_name = (DeregisterCluster -> Text)
-> (DeregisterCluster -> Text -> DeregisterCluster)
-> Lens DeregisterCluster DeregisterCluster Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterCluster' {Text
name :: Text
$sel:name:DeregisterCluster' :: DeregisterCluster -> Text
name} -> Text
name) (\s :: DeregisterCluster
s@DeregisterCluster' {} Text
a -> DeregisterCluster
s {$sel:name:DeregisterCluster' :: Text
name = Text
a} :: DeregisterCluster)

instance Core.AWSRequest DeregisterCluster where
  type
    AWSResponse DeregisterCluster =
      DeregisterClusterResponse
  request :: DeregisterCluster -> Request DeregisterCluster
request = Service -> DeregisterCluster -> Request DeregisterCluster
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeregisterCluster
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterCluster)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeregisterCluster))
-> Logger
-> Service
-> Proxy DeregisterCluster
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterCluster)))
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 Cluster -> Int -> DeregisterClusterResponse
DeregisterClusterResponse'
            (Maybe Cluster -> Int -> DeregisterClusterResponse)
-> Either String (Maybe Cluster)
-> Either String (Int -> DeregisterClusterResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Cluster)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"cluster")
            Either String (Int -> DeregisterClusterResponse)
-> Either String Int -> Either String DeregisterClusterResponse
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 DeregisterCluster

instance Prelude.NFData DeregisterCluster

instance Core.ToHeaders DeregisterCluster where
  toHeaders :: DeregisterCluster -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeregisterCluster -> 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 DeregisterCluster where
  toPath :: DeregisterCluster -> ByteString
toPath DeregisterCluster' {Text
name :: Text
$sel:name:DeregisterCluster' :: DeregisterCluster -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/cluster-registrations/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
name]

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

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

-- |
-- Create a value of 'DeregisterClusterResponse' 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:
--
-- 'cluster', 'deregisterClusterResponse_cluster' - Undocumented member.
--
-- 'httpStatus', 'deregisterClusterResponse_httpStatus' - The response's http status code.
newDeregisterClusterResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeregisterClusterResponse
newDeregisterClusterResponse :: Int -> DeregisterClusterResponse
newDeregisterClusterResponse Int
pHttpStatus_ =
  DeregisterClusterResponse' :: Maybe Cluster -> Int -> DeregisterClusterResponse
DeregisterClusterResponse'
    { $sel:cluster:DeregisterClusterResponse' :: Maybe Cluster
cluster =
        Maybe Cluster
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeregisterClusterResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
deregisterClusterResponse_cluster :: Lens.Lens' DeregisterClusterResponse (Prelude.Maybe Cluster)
deregisterClusterResponse_cluster :: (Maybe Cluster -> f (Maybe Cluster))
-> DeregisterClusterResponse -> f DeregisterClusterResponse
deregisterClusterResponse_cluster = (DeregisterClusterResponse -> Maybe Cluster)
-> (DeregisterClusterResponse
    -> Maybe Cluster -> DeregisterClusterResponse)
-> Lens
     DeregisterClusterResponse
     DeregisterClusterResponse
     (Maybe Cluster)
     (Maybe Cluster)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterClusterResponse' {Maybe Cluster
cluster :: Maybe Cluster
$sel:cluster:DeregisterClusterResponse' :: DeregisterClusterResponse -> Maybe Cluster
cluster} -> Maybe Cluster
cluster) (\s :: DeregisterClusterResponse
s@DeregisterClusterResponse' {} Maybe Cluster
a -> DeregisterClusterResponse
s {$sel:cluster:DeregisterClusterResponse' :: Maybe Cluster
cluster = Maybe Cluster
a} :: DeregisterClusterResponse)

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

instance Prelude.NFData DeregisterClusterResponse