{-# 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.EC2.UnmonitorInstances
-- 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 detailed monitoring for a running instance. For more
-- information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-cloudwatch.html Monitoring your instances and volumes>
-- in the /Amazon EC2 User Guide/.
module Amazonka.EC2.UnmonitorInstances
  ( -- * Creating a Request
    UnmonitorInstances (..),
    newUnmonitorInstances,

    -- * Request Lenses
    unmonitorInstances_dryRun,
    unmonitorInstances_instanceIds,

    -- * Destructuring the Response
    UnmonitorInstancesResponse (..),
    newUnmonitorInstancesResponse,

    -- * Response Lenses
    unmonitorInstancesResponse_instanceMonitorings,
    unmonitorInstancesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUnmonitorInstances' smart constructor.
data UnmonitorInstances = UnmonitorInstances'
  { -- | Checks whether you have the required permissions for the action, without
    -- actually making the request, and provides an error response. If you have
    -- the required permissions, the error response is @DryRunOperation@.
    -- Otherwise, it is @UnauthorizedOperation@.
    UnmonitorInstances -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The IDs of the instances.
    UnmonitorInstances -> [Text]
instanceIds :: [Prelude.Text]
  }
  deriving (UnmonitorInstances -> UnmonitorInstances -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnmonitorInstances -> UnmonitorInstances -> Bool
$c/= :: UnmonitorInstances -> UnmonitorInstances -> Bool
== :: UnmonitorInstances -> UnmonitorInstances -> Bool
$c== :: UnmonitorInstances -> UnmonitorInstances -> Bool
Prelude.Eq, ReadPrec [UnmonitorInstances]
ReadPrec UnmonitorInstances
Int -> ReadS UnmonitorInstances
ReadS [UnmonitorInstances]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UnmonitorInstances]
$creadListPrec :: ReadPrec [UnmonitorInstances]
readPrec :: ReadPrec UnmonitorInstances
$creadPrec :: ReadPrec UnmonitorInstances
readList :: ReadS [UnmonitorInstances]
$creadList :: ReadS [UnmonitorInstances]
readsPrec :: Int -> ReadS UnmonitorInstances
$creadsPrec :: Int -> ReadS UnmonitorInstances
Prelude.Read, Int -> UnmonitorInstances -> ShowS
[UnmonitorInstances] -> ShowS
UnmonitorInstances -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnmonitorInstances] -> ShowS
$cshowList :: [UnmonitorInstances] -> ShowS
show :: UnmonitorInstances -> String
$cshow :: UnmonitorInstances -> String
showsPrec :: Int -> UnmonitorInstances -> ShowS
$cshowsPrec :: Int -> UnmonitorInstances -> ShowS
Prelude.Show, forall x. Rep UnmonitorInstances x -> UnmonitorInstances
forall x. UnmonitorInstances -> Rep UnmonitorInstances x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UnmonitorInstances x -> UnmonitorInstances
$cfrom :: forall x. UnmonitorInstances -> Rep UnmonitorInstances x
Prelude.Generic)

-- |
-- Create a value of 'UnmonitorInstances' 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:
--
-- 'dryRun', 'unmonitorInstances_dryRun' - Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
--
-- 'instanceIds', 'unmonitorInstances_instanceIds' - The IDs of the instances.
newUnmonitorInstances ::
  UnmonitorInstances
newUnmonitorInstances :: UnmonitorInstances
newUnmonitorInstances =
  UnmonitorInstances'
    { $sel:dryRun:UnmonitorInstances' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceIds:UnmonitorInstances' :: [Text]
instanceIds = forall a. Monoid a => a
Prelude.mempty
    }

-- | Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
unmonitorInstances_dryRun :: Lens.Lens' UnmonitorInstances (Prelude.Maybe Prelude.Bool)
unmonitorInstances_dryRun :: Lens' UnmonitorInstances (Maybe Bool)
unmonitorInstances_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnmonitorInstances' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:UnmonitorInstances' :: UnmonitorInstances -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: UnmonitorInstances
s@UnmonitorInstances' {} Maybe Bool
a -> UnmonitorInstances
s {$sel:dryRun:UnmonitorInstances' :: Maybe Bool
dryRun = Maybe Bool
a} :: UnmonitorInstances)

-- | The IDs of the instances.
unmonitorInstances_instanceIds :: Lens.Lens' UnmonitorInstances [Prelude.Text]
unmonitorInstances_instanceIds :: Lens' UnmonitorInstances [Text]
unmonitorInstances_instanceIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnmonitorInstances' {[Text]
instanceIds :: [Text]
$sel:instanceIds:UnmonitorInstances' :: UnmonitorInstances -> [Text]
instanceIds} -> [Text]
instanceIds) (\s :: UnmonitorInstances
s@UnmonitorInstances' {} [Text]
a -> UnmonitorInstances
s {$sel:instanceIds:UnmonitorInstances' :: [Text]
instanceIds = [Text]
a} :: UnmonitorInstances) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest UnmonitorInstances where
  type
    AWSResponse UnmonitorInstances =
      UnmonitorInstancesResponse
  request :: (Service -> Service)
-> UnmonitorInstances -> Request UnmonitorInstances
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UnmonitorInstances
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UnmonitorInstances)))
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 [InstanceMonitoring] -> Int -> UnmonitorInstancesResponse
UnmonitorInstancesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"instancesSet"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                        )
            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 UnmonitorInstances where
  hashWithSalt :: Int -> UnmonitorInstances -> Int
hashWithSalt Int
_salt UnmonitorInstances' {[Text]
Maybe Bool
instanceIds :: [Text]
dryRun :: Maybe Bool
$sel:instanceIds:UnmonitorInstances' :: UnmonitorInstances -> [Text]
$sel:dryRun:UnmonitorInstances' :: UnmonitorInstances -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
instanceIds

instance Prelude.NFData UnmonitorInstances where
  rnf :: UnmonitorInstances -> ()
rnf UnmonitorInstances' {[Text]
Maybe Bool
instanceIds :: [Text]
dryRun :: Maybe Bool
$sel:instanceIds:UnmonitorInstances' :: UnmonitorInstances -> [Text]
$sel:dryRun:UnmonitorInstances' :: UnmonitorInstances -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
instanceIds

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

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

instance Data.ToQuery UnmonitorInstances where
  toQuery :: UnmonitorInstances -> QueryString
toQuery UnmonitorInstances' {[Text]
Maybe Bool
instanceIds :: [Text]
dryRun :: Maybe Bool
$sel:instanceIds:UnmonitorInstances' :: UnmonitorInstances -> [Text]
$sel:dryRun:UnmonitorInstances' :: UnmonitorInstances -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"UnmonitorInstances" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2016-11-15" :: Prelude.ByteString),
        ByteString
"DryRun" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
dryRun,
        forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"InstanceId" [Text]
instanceIds
      ]

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

-- |
-- Create a value of 'UnmonitorInstancesResponse' 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:
--
-- 'instanceMonitorings', 'unmonitorInstancesResponse_instanceMonitorings' - The monitoring information.
--
-- 'httpStatus', 'unmonitorInstancesResponse_httpStatus' - The response's http status code.
newUnmonitorInstancesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UnmonitorInstancesResponse
newUnmonitorInstancesResponse :: Int -> UnmonitorInstancesResponse
newUnmonitorInstancesResponse Int
pHttpStatus_ =
  UnmonitorInstancesResponse'
    { $sel:instanceMonitorings:UnmonitorInstancesResponse' :: Maybe [InstanceMonitoring]
instanceMonitorings =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UnmonitorInstancesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The monitoring information.
unmonitorInstancesResponse_instanceMonitorings :: Lens.Lens' UnmonitorInstancesResponse (Prelude.Maybe [InstanceMonitoring])
unmonitorInstancesResponse_instanceMonitorings :: Lens' UnmonitorInstancesResponse (Maybe [InstanceMonitoring])
unmonitorInstancesResponse_instanceMonitorings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnmonitorInstancesResponse' {Maybe [InstanceMonitoring]
instanceMonitorings :: Maybe [InstanceMonitoring]
$sel:instanceMonitorings:UnmonitorInstancesResponse' :: UnmonitorInstancesResponse -> Maybe [InstanceMonitoring]
instanceMonitorings} -> Maybe [InstanceMonitoring]
instanceMonitorings) (\s :: UnmonitorInstancesResponse
s@UnmonitorInstancesResponse' {} Maybe [InstanceMonitoring]
a -> UnmonitorInstancesResponse
s {$sel:instanceMonitorings:UnmonitorInstancesResponse' :: Maybe [InstanceMonitoring]
instanceMonitorings = Maybe [InstanceMonitoring]
a} :: UnmonitorInstancesResponse) 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.
unmonitorInstancesResponse_httpStatus :: Lens.Lens' UnmonitorInstancesResponse Prelude.Int
unmonitorInstancesResponse_httpStatus :: Lens' UnmonitorInstancesResponse Int
unmonitorInstancesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnmonitorInstancesResponse' {Int
httpStatus :: Int
$sel:httpStatus:UnmonitorInstancesResponse' :: UnmonitorInstancesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UnmonitorInstancesResponse
s@UnmonitorInstancesResponse' {} Int
a -> UnmonitorInstancesResponse
s {$sel:httpStatus:UnmonitorInstancesResponse' :: Int
httpStatus = Int
a} :: UnmonitorInstancesResponse)

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