{-# 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.DisableAddOn
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disables an add-on for an Amazon Lightsail resource. For more
-- information, see the
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-configuring-automatic-snapshots Amazon Lightsail Developer Guide>.
module Amazonka.Lightsail.DisableAddOn
  ( -- * Creating a Request
    DisableAddOn (..),
    newDisableAddOn,

    -- * Request Lenses
    disableAddOn_addOnType,
    disableAddOn_resourceName,

    -- * Destructuring the Response
    DisableAddOnResponse (..),
    newDisableAddOnResponse,

    -- * Response Lenses
    disableAddOnResponse_operations,
    disableAddOnResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDisableAddOn' smart constructor.
data DisableAddOn = DisableAddOn'
  { -- | The add-on type to disable.
    DisableAddOn -> AddOnType
addOnType :: AddOnType,
    -- | The name of the source resource for which to disable the add-on.
    DisableAddOn -> Text
resourceName :: Prelude.Text
  }
  deriving (DisableAddOn -> DisableAddOn -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableAddOn -> DisableAddOn -> Bool
$c/= :: DisableAddOn -> DisableAddOn -> Bool
== :: DisableAddOn -> DisableAddOn -> Bool
$c== :: DisableAddOn -> DisableAddOn -> Bool
Prelude.Eq, ReadPrec [DisableAddOn]
ReadPrec DisableAddOn
Int -> ReadS DisableAddOn
ReadS [DisableAddOn]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableAddOn]
$creadListPrec :: ReadPrec [DisableAddOn]
readPrec :: ReadPrec DisableAddOn
$creadPrec :: ReadPrec DisableAddOn
readList :: ReadS [DisableAddOn]
$creadList :: ReadS [DisableAddOn]
readsPrec :: Int -> ReadS DisableAddOn
$creadsPrec :: Int -> ReadS DisableAddOn
Prelude.Read, Int -> DisableAddOn -> ShowS
[DisableAddOn] -> ShowS
DisableAddOn -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableAddOn] -> ShowS
$cshowList :: [DisableAddOn] -> ShowS
show :: DisableAddOn -> String
$cshow :: DisableAddOn -> String
showsPrec :: Int -> DisableAddOn -> ShowS
$cshowsPrec :: Int -> DisableAddOn -> ShowS
Prelude.Show, forall x. Rep DisableAddOn x -> DisableAddOn
forall x. DisableAddOn -> Rep DisableAddOn x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisableAddOn x -> DisableAddOn
$cfrom :: forall x. DisableAddOn -> Rep DisableAddOn x
Prelude.Generic)

-- |
-- Create a value of 'DisableAddOn' 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:
--
-- 'addOnType', 'disableAddOn_addOnType' - The add-on type to disable.
--
-- 'resourceName', 'disableAddOn_resourceName' - The name of the source resource for which to disable the add-on.
newDisableAddOn ::
  -- | 'addOnType'
  AddOnType ->
  -- | 'resourceName'
  Prelude.Text ->
  DisableAddOn
newDisableAddOn :: AddOnType -> Text -> DisableAddOn
newDisableAddOn AddOnType
pAddOnType_ Text
pResourceName_ =
  DisableAddOn'
    { $sel:addOnType:DisableAddOn' :: AddOnType
addOnType = AddOnType
pAddOnType_,
      $sel:resourceName:DisableAddOn' :: Text
resourceName = Text
pResourceName_
    }

-- | The add-on type to disable.
disableAddOn_addOnType :: Lens.Lens' DisableAddOn AddOnType
disableAddOn_addOnType :: Lens' DisableAddOn AddOnType
disableAddOn_addOnType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableAddOn' {AddOnType
addOnType :: AddOnType
$sel:addOnType:DisableAddOn' :: DisableAddOn -> AddOnType
addOnType} -> AddOnType
addOnType) (\s :: DisableAddOn
s@DisableAddOn' {} AddOnType
a -> DisableAddOn
s {$sel:addOnType:DisableAddOn' :: AddOnType
addOnType = AddOnType
a} :: DisableAddOn)

-- | The name of the source resource for which to disable the add-on.
disableAddOn_resourceName :: Lens.Lens' DisableAddOn Prelude.Text
disableAddOn_resourceName :: Lens' DisableAddOn Text
disableAddOn_resourceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableAddOn' {Text
resourceName :: Text
$sel:resourceName:DisableAddOn' :: DisableAddOn -> Text
resourceName} -> Text
resourceName) (\s :: DisableAddOn
s@DisableAddOn' {} Text
a -> DisableAddOn
s {$sel:resourceName:DisableAddOn' :: Text
resourceName = Text
a} :: DisableAddOn)

instance Core.AWSRequest DisableAddOn where
  type AWSResponse DisableAddOn = DisableAddOnResponse
  request :: (Service -> Service) -> DisableAddOn -> Request DisableAddOn
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DisableAddOn
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DisableAddOn)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Operation] -> Int -> DisableAddOnResponse
DisableAddOnResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"operations" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 DisableAddOn where
  hashWithSalt :: Int -> DisableAddOn -> Int
hashWithSalt Int
_salt DisableAddOn' {Text
AddOnType
resourceName :: Text
addOnType :: AddOnType
$sel:resourceName:DisableAddOn' :: DisableAddOn -> Text
$sel:addOnType:DisableAddOn' :: DisableAddOn -> AddOnType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AddOnType
addOnType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceName

instance Prelude.NFData DisableAddOn where
  rnf :: DisableAddOn -> ()
rnf DisableAddOn' {Text
AddOnType
resourceName :: Text
addOnType :: AddOnType
$sel:resourceName:DisableAddOn' :: DisableAddOn -> Text
$sel:addOnType:DisableAddOn' :: DisableAddOn -> AddOnType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf AddOnType
addOnType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceName

instance Data.ToHeaders DisableAddOn where
  toHeaders :: DisableAddOn -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"Lightsail_20161128.DisableAddOn" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DisableAddOn where
  toJSON :: DisableAddOn -> Value
toJSON DisableAddOn' {Text
AddOnType
resourceName :: Text
addOnType :: AddOnType
$sel:resourceName:DisableAddOn' :: DisableAddOn -> Text
$sel:addOnType:DisableAddOn' :: DisableAddOn -> AddOnType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"addOnType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AddOnType
addOnType),
            forall a. a -> Maybe a
Prelude.Just (Key
"resourceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceName)
          ]
      )

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

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

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

-- |
-- Create a value of 'DisableAddOnResponse' 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:
--
-- 'operations', 'disableAddOnResponse_operations' - An array of objects that describe 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', 'disableAddOnResponse_httpStatus' - The response's http status code.
newDisableAddOnResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisableAddOnResponse
newDisableAddOnResponse :: Int -> DisableAddOnResponse
newDisableAddOnResponse Int
pHttpStatus_ =
  DisableAddOnResponse'
    { $sel:operations:DisableAddOnResponse' :: Maybe [Operation]
operations = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisableAddOnResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
disableAddOnResponse_operations :: Lens.Lens' DisableAddOnResponse (Prelude.Maybe [Operation])
disableAddOnResponse_operations :: Lens' DisableAddOnResponse (Maybe [Operation])
disableAddOnResponse_operations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableAddOnResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:DisableAddOnResponse' :: DisableAddOnResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: DisableAddOnResponse
s@DisableAddOnResponse' {} Maybe [Operation]
a -> DisableAddOnResponse
s {$sel:operations:DisableAddOnResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: DisableAddOnResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DisableAddOnResponse where
  rnf :: DisableAddOnResponse -> ()
rnf DisableAddOnResponse' {Int
Maybe [Operation]
httpStatus :: Int
operations :: Maybe [Operation]
$sel:httpStatus:DisableAddOnResponse' :: DisableAddOnResponse -> Int
$sel:operations:DisableAddOnResponse' :: DisableAddOnResponse -> Maybe [Operation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Operation]
operations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus