{-# 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.Lightsail.DetachCertificateFromDistribution
-- 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)
--
-- Detaches an SSL\/TLS certificate from your Amazon Lightsail content
-- delivery network (CDN) distribution.
--
-- After the certificate is detached, your distribution stops accepting
-- traffic for all of the domains that are associated with the certificate.
module Amazonka.Lightsail.DetachCertificateFromDistribution
  ( -- * Creating a Request
    DetachCertificateFromDistribution (..),
    newDetachCertificateFromDistribution,

    -- * Request Lenses
    detachCertificateFromDistribution_distributionName,

    -- * Destructuring the Response
    DetachCertificateFromDistributionResponse (..),
    newDetachCertificateFromDistributionResponse,

    -- * Response Lenses
    detachCertificateFromDistributionResponse_operation,
    detachCertificateFromDistributionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDetachCertificateFromDistribution' smart constructor.
data DetachCertificateFromDistribution = DetachCertificateFromDistribution'
  { -- | The name of the distribution from which to detach the certificate.
    --
    -- Use the @GetDistributions@ action to get a list of distribution names
    -- that you can specify.
    DetachCertificateFromDistribution -> Text
distributionName :: Prelude.Text
  }
  deriving (DetachCertificateFromDistribution
-> DetachCertificateFromDistribution -> Bool
(DetachCertificateFromDistribution
 -> DetachCertificateFromDistribution -> Bool)
-> (DetachCertificateFromDistribution
    -> DetachCertificateFromDistribution -> Bool)
-> Eq DetachCertificateFromDistribution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetachCertificateFromDistribution
-> DetachCertificateFromDistribution -> Bool
$c/= :: DetachCertificateFromDistribution
-> DetachCertificateFromDistribution -> Bool
== :: DetachCertificateFromDistribution
-> DetachCertificateFromDistribution -> Bool
$c== :: DetachCertificateFromDistribution
-> DetachCertificateFromDistribution -> Bool
Prelude.Eq, ReadPrec [DetachCertificateFromDistribution]
ReadPrec DetachCertificateFromDistribution
Int -> ReadS DetachCertificateFromDistribution
ReadS [DetachCertificateFromDistribution]
(Int -> ReadS DetachCertificateFromDistribution)
-> ReadS [DetachCertificateFromDistribution]
-> ReadPrec DetachCertificateFromDistribution
-> ReadPrec [DetachCertificateFromDistribution]
-> Read DetachCertificateFromDistribution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetachCertificateFromDistribution]
$creadListPrec :: ReadPrec [DetachCertificateFromDistribution]
readPrec :: ReadPrec DetachCertificateFromDistribution
$creadPrec :: ReadPrec DetachCertificateFromDistribution
readList :: ReadS [DetachCertificateFromDistribution]
$creadList :: ReadS [DetachCertificateFromDistribution]
readsPrec :: Int -> ReadS DetachCertificateFromDistribution
$creadsPrec :: Int -> ReadS DetachCertificateFromDistribution
Prelude.Read, Int -> DetachCertificateFromDistribution -> ShowS
[DetachCertificateFromDistribution] -> ShowS
DetachCertificateFromDistribution -> String
(Int -> DetachCertificateFromDistribution -> ShowS)
-> (DetachCertificateFromDistribution -> String)
-> ([DetachCertificateFromDistribution] -> ShowS)
-> Show DetachCertificateFromDistribution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetachCertificateFromDistribution] -> ShowS
$cshowList :: [DetachCertificateFromDistribution] -> ShowS
show :: DetachCertificateFromDistribution -> String
$cshow :: DetachCertificateFromDistribution -> String
showsPrec :: Int -> DetachCertificateFromDistribution -> ShowS
$cshowsPrec :: Int -> DetachCertificateFromDistribution -> ShowS
Prelude.Show, (forall x.
 DetachCertificateFromDistribution
 -> Rep DetachCertificateFromDistribution x)
-> (forall x.
    Rep DetachCertificateFromDistribution x
    -> DetachCertificateFromDistribution)
-> Generic DetachCertificateFromDistribution
forall x.
Rep DetachCertificateFromDistribution x
-> DetachCertificateFromDistribution
forall x.
DetachCertificateFromDistribution
-> Rep DetachCertificateFromDistribution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DetachCertificateFromDistribution x
-> DetachCertificateFromDistribution
$cfrom :: forall x.
DetachCertificateFromDistribution
-> Rep DetachCertificateFromDistribution x
Prelude.Generic)

-- |
-- Create a value of 'DetachCertificateFromDistribution' 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:
--
-- 'distributionName', 'detachCertificateFromDistribution_distributionName' - The name of the distribution from which to detach the certificate.
--
-- Use the @GetDistributions@ action to get a list of distribution names
-- that you can specify.
newDetachCertificateFromDistribution ::
  -- | 'distributionName'
  Prelude.Text ->
  DetachCertificateFromDistribution
newDetachCertificateFromDistribution :: Text -> DetachCertificateFromDistribution
newDetachCertificateFromDistribution
  Text
pDistributionName_ =
    DetachCertificateFromDistribution' :: Text -> DetachCertificateFromDistribution
DetachCertificateFromDistribution'
      { $sel:distributionName:DetachCertificateFromDistribution' :: Text
distributionName =
          Text
pDistributionName_
      }

-- | The name of the distribution from which to detach the certificate.
--
-- Use the @GetDistributions@ action to get a list of distribution names
-- that you can specify.
detachCertificateFromDistribution_distributionName :: Lens.Lens' DetachCertificateFromDistribution Prelude.Text
detachCertificateFromDistribution_distributionName :: (Text -> f Text)
-> DetachCertificateFromDistribution
-> f DetachCertificateFromDistribution
detachCertificateFromDistribution_distributionName = (DetachCertificateFromDistribution -> Text)
-> (DetachCertificateFromDistribution
    -> Text -> DetachCertificateFromDistribution)
-> Lens
     DetachCertificateFromDistribution
     DetachCertificateFromDistribution
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachCertificateFromDistribution' {Text
distributionName :: Text
$sel:distributionName:DetachCertificateFromDistribution' :: DetachCertificateFromDistribution -> Text
distributionName} -> Text
distributionName) (\s :: DetachCertificateFromDistribution
s@DetachCertificateFromDistribution' {} Text
a -> DetachCertificateFromDistribution
s {$sel:distributionName:DetachCertificateFromDistribution' :: Text
distributionName = Text
a} :: DetachCertificateFromDistribution)

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

instance
  Prelude.NFData
    DetachCertificateFromDistribution

instance
  Core.ToHeaders
    DetachCertificateFromDistribution
  where
  toHeaders :: DetachCertificateFromDistribution -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> DetachCertificateFromDistribution -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Lightsail_20161128.DetachCertificateFromDistribution" ::
                          Prelude.ByteString
                      ),
            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.ToJSON
    DetachCertificateFromDistribution
  where
  toJSON :: DetachCertificateFromDistribution -> Value
toJSON DetachCertificateFromDistribution' {Text
distributionName :: Text
$sel:distributionName:DetachCertificateFromDistribution' :: DetachCertificateFromDistribution -> Text
..} =
    [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
"distributionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
distributionName)
          ]
      )

instance
  Core.ToPath
    DetachCertificateFromDistribution
  where
  toPath :: DetachCertificateFromDistribution -> ByteString
toPath = ByteString -> DetachCertificateFromDistribution -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDetachCertificateFromDistributionResponse' smart constructor.
data DetachCertificateFromDistributionResponse = DetachCertificateFromDistributionResponse'
  { -- | An object that describes the result of the action, such as the status of
    -- the request, the timestamp of the request, and the resources affected by
    -- the request.
    DetachCertificateFromDistributionResponse -> Maybe Operation
operation :: Prelude.Maybe Operation,
    -- | The response's http status code.
    DetachCertificateFromDistributionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DetachCertificateFromDistributionResponse
-> DetachCertificateFromDistributionResponse -> Bool
(DetachCertificateFromDistributionResponse
 -> DetachCertificateFromDistributionResponse -> Bool)
-> (DetachCertificateFromDistributionResponse
    -> DetachCertificateFromDistributionResponse -> Bool)
-> Eq DetachCertificateFromDistributionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetachCertificateFromDistributionResponse
-> DetachCertificateFromDistributionResponse -> Bool
$c/= :: DetachCertificateFromDistributionResponse
-> DetachCertificateFromDistributionResponse -> Bool
== :: DetachCertificateFromDistributionResponse
-> DetachCertificateFromDistributionResponse -> Bool
$c== :: DetachCertificateFromDistributionResponse
-> DetachCertificateFromDistributionResponse -> Bool
Prelude.Eq, ReadPrec [DetachCertificateFromDistributionResponse]
ReadPrec DetachCertificateFromDistributionResponse
Int -> ReadS DetachCertificateFromDistributionResponse
ReadS [DetachCertificateFromDistributionResponse]
(Int -> ReadS DetachCertificateFromDistributionResponse)
-> ReadS [DetachCertificateFromDistributionResponse]
-> ReadPrec DetachCertificateFromDistributionResponse
-> ReadPrec [DetachCertificateFromDistributionResponse]
-> Read DetachCertificateFromDistributionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetachCertificateFromDistributionResponse]
$creadListPrec :: ReadPrec [DetachCertificateFromDistributionResponse]
readPrec :: ReadPrec DetachCertificateFromDistributionResponse
$creadPrec :: ReadPrec DetachCertificateFromDistributionResponse
readList :: ReadS [DetachCertificateFromDistributionResponse]
$creadList :: ReadS [DetachCertificateFromDistributionResponse]
readsPrec :: Int -> ReadS DetachCertificateFromDistributionResponse
$creadsPrec :: Int -> ReadS DetachCertificateFromDistributionResponse
Prelude.Read, Int -> DetachCertificateFromDistributionResponse -> ShowS
[DetachCertificateFromDistributionResponse] -> ShowS
DetachCertificateFromDistributionResponse -> String
(Int -> DetachCertificateFromDistributionResponse -> ShowS)
-> (DetachCertificateFromDistributionResponse -> String)
-> ([DetachCertificateFromDistributionResponse] -> ShowS)
-> Show DetachCertificateFromDistributionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetachCertificateFromDistributionResponse] -> ShowS
$cshowList :: [DetachCertificateFromDistributionResponse] -> ShowS
show :: DetachCertificateFromDistributionResponse -> String
$cshow :: DetachCertificateFromDistributionResponse -> String
showsPrec :: Int -> DetachCertificateFromDistributionResponse -> ShowS
$cshowsPrec :: Int -> DetachCertificateFromDistributionResponse -> ShowS
Prelude.Show, (forall x.
 DetachCertificateFromDistributionResponse
 -> Rep DetachCertificateFromDistributionResponse x)
-> (forall x.
    Rep DetachCertificateFromDistributionResponse x
    -> DetachCertificateFromDistributionResponse)
-> Generic DetachCertificateFromDistributionResponse
forall x.
Rep DetachCertificateFromDistributionResponse x
-> DetachCertificateFromDistributionResponse
forall x.
DetachCertificateFromDistributionResponse
-> Rep DetachCertificateFromDistributionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DetachCertificateFromDistributionResponse x
-> DetachCertificateFromDistributionResponse
$cfrom :: forall x.
DetachCertificateFromDistributionResponse
-> Rep DetachCertificateFromDistributionResponse x
Prelude.Generic)

-- |
-- Create a value of 'DetachCertificateFromDistributionResponse' 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:
--
-- 'operation', 'detachCertificateFromDistributionResponse_operation' - An object that describes the result of the action, such as the status of
-- the request, the timestamp of the request, and the resources affected by
-- the request.
--
-- 'httpStatus', 'detachCertificateFromDistributionResponse_httpStatus' - The response's http status code.
newDetachCertificateFromDistributionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DetachCertificateFromDistributionResponse
newDetachCertificateFromDistributionResponse :: Int -> DetachCertificateFromDistributionResponse
newDetachCertificateFromDistributionResponse
  Int
pHttpStatus_ =
    DetachCertificateFromDistributionResponse' :: Maybe Operation -> Int -> DetachCertificateFromDistributionResponse
DetachCertificateFromDistributionResponse'
      { $sel:operation:DetachCertificateFromDistributionResponse' :: Maybe Operation
operation =
          Maybe Operation
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DetachCertificateFromDistributionResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | An object that describes the result of the action, such as the status of
-- the request, the timestamp of the request, and the resources affected by
-- the request.
detachCertificateFromDistributionResponse_operation :: Lens.Lens' DetachCertificateFromDistributionResponse (Prelude.Maybe Operation)
detachCertificateFromDistributionResponse_operation :: (Maybe Operation -> f (Maybe Operation))
-> DetachCertificateFromDistributionResponse
-> f DetachCertificateFromDistributionResponse
detachCertificateFromDistributionResponse_operation = (DetachCertificateFromDistributionResponse -> Maybe Operation)
-> (DetachCertificateFromDistributionResponse
    -> Maybe Operation -> DetachCertificateFromDistributionResponse)
-> Lens
     DetachCertificateFromDistributionResponse
     DetachCertificateFromDistributionResponse
     (Maybe Operation)
     (Maybe Operation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachCertificateFromDistributionResponse' {Maybe Operation
operation :: Maybe Operation
$sel:operation:DetachCertificateFromDistributionResponse' :: DetachCertificateFromDistributionResponse -> Maybe Operation
operation} -> Maybe Operation
operation) (\s :: DetachCertificateFromDistributionResponse
s@DetachCertificateFromDistributionResponse' {} Maybe Operation
a -> DetachCertificateFromDistributionResponse
s {$sel:operation:DetachCertificateFromDistributionResponse' :: Maybe Operation
operation = Maybe Operation
a} :: DetachCertificateFromDistributionResponse)

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

instance
  Prelude.NFData
    DetachCertificateFromDistributionResponse