{-# 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.CloudWatch.StopMetricStreams
-- 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)
--
-- Stops the streaming of metrics for one or more of your metric streams.
module Amazonka.CloudWatch.StopMetricStreams
  ( -- * Creating a Request
    StopMetricStreams (..),
    newStopMetricStreams,

    -- * Request Lenses
    stopMetricStreams_names,

    -- * Destructuring the Response
    StopMetricStreamsResponse (..),
    newStopMetricStreamsResponse,

    -- * Response Lenses
    stopMetricStreamsResponse_httpStatus,
  )
where

import Amazonka.CloudWatch.Types
import qualified Amazonka.Core as Core
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:/ 'newStopMetricStreams' smart constructor.
data StopMetricStreams = StopMetricStreams'
  { -- | The array of the names of metric streams to stop streaming.
    --
    -- This is an \"all or nothing\" operation. If you do not have permission
    -- to access all of the metric streams that you list here, then none of the
    -- streams that you list in the operation will stop streaming.
    StopMetricStreams -> [Text]
names :: [Prelude.Text]
  }
  deriving (StopMetricStreams -> StopMetricStreams -> Bool
(StopMetricStreams -> StopMetricStreams -> Bool)
-> (StopMetricStreams -> StopMetricStreams -> Bool)
-> Eq StopMetricStreams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopMetricStreams -> StopMetricStreams -> Bool
$c/= :: StopMetricStreams -> StopMetricStreams -> Bool
== :: StopMetricStreams -> StopMetricStreams -> Bool
$c== :: StopMetricStreams -> StopMetricStreams -> Bool
Prelude.Eq, ReadPrec [StopMetricStreams]
ReadPrec StopMetricStreams
Int -> ReadS StopMetricStreams
ReadS [StopMetricStreams]
(Int -> ReadS StopMetricStreams)
-> ReadS [StopMetricStreams]
-> ReadPrec StopMetricStreams
-> ReadPrec [StopMetricStreams]
-> Read StopMetricStreams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopMetricStreams]
$creadListPrec :: ReadPrec [StopMetricStreams]
readPrec :: ReadPrec StopMetricStreams
$creadPrec :: ReadPrec StopMetricStreams
readList :: ReadS [StopMetricStreams]
$creadList :: ReadS [StopMetricStreams]
readsPrec :: Int -> ReadS StopMetricStreams
$creadsPrec :: Int -> ReadS StopMetricStreams
Prelude.Read, Int -> StopMetricStreams -> ShowS
[StopMetricStreams] -> ShowS
StopMetricStreams -> String
(Int -> StopMetricStreams -> ShowS)
-> (StopMetricStreams -> String)
-> ([StopMetricStreams] -> ShowS)
-> Show StopMetricStreams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopMetricStreams] -> ShowS
$cshowList :: [StopMetricStreams] -> ShowS
show :: StopMetricStreams -> String
$cshow :: StopMetricStreams -> String
showsPrec :: Int -> StopMetricStreams -> ShowS
$cshowsPrec :: Int -> StopMetricStreams -> ShowS
Prelude.Show, (forall x. StopMetricStreams -> Rep StopMetricStreams x)
-> (forall x. Rep StopMetricStreams x -> StopMetricStreams)
-> Generic StopMetricStreams
forall x. Rep StopMetricStreams x -> StopMetricStreams
forall x. StopMetricStreams -> Rep StopMetricStreams x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopMetricStreams x -> StopMetricStreams
$cfrom :: forall x. StopMetricStreams -> Rep StopMetricStreams x
Prelude.Generic)

-- |
-- Create a value of 'StopMetricStreams' 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:
--
-- 'names', 'stopMetricStreams_names' - The array of the names of metric streams to stop streaming.
--
-- This is an \"all or nothing\" operation. If you do not have permission
-- to access all of the metric streams that you list here, then none of the
-- streams that you list in the operation will stop streaming.
newStopMetricStreams ::
  StopMetricStreams
newStopMetricStreams :: StopMetricStreams
newStopMetricStreams =
  StopMetricStreams' :: [Text] -> StopMetricStreams
StopMetricStreams' {$sel:names:StopMetricStreams' :: [Text]
names = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | The array of the names of metric streams to stop streaming.
--
-- This is an \"all or nothing\" operation. If you do not have permission
-- to access all of the metric streams that you list here, then none of the
-- streams that you list in the operation will stop streaming.
stopMetricStreams_names :: Lens.Lens' StopMetricStreams [Prelude.Text]
stopMetricStreams_names :: ([Text] -> f [Text]) -> StopMetricStreams -> f StopMetricStreams
stopMetricStreams_names = (StopMetricStreams -> [Text])
-> (StopMetricStreams -> [Text] -> StopMetricStreams)
-> Lens StopMetricStreams StopMetricStreams [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopMetricStreams' {[Text]
names :: [Text]
$sel:names:StopMetricStreams' :: StopMetricStreams -> [Text]
names} -> [Text]
names) (\s :: StopMetricStreams
s@StopMetricStreams' {} [Text]
a -> StopMetricStreams
s {$sel:names:StopMetricStreams' :: [Text]
names = [Text]
a} :: StopMetricStreams) (([Text] -> f [Text]) -> StopMetricStreams -> f StopMetricStreams)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> StopMetricStreams
-> f StopMetricStreams
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest StopMetricStreams where
  type
    AWSResponse StopMetricStreams =
      StopMetricStreamsResponse
  request :: StopMetricStreams -> Request StopMetricStreams
request = Service -> StopMetricStreams -> Request StopMetricStreams
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy StopMetricStreams
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopMetricStreams)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse StopMetricStreams))
-> Logger
-> Service
-> Proxy StopMetricStreams
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopMetricStreams)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"StopMetricStreamsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> StopMetricStreamsResponse
StopMetricStreamsResponse'
            (Int -> StopMetricStreamsResponse)
-> Either String Int -> Either String StopMetricStreamsResponse
forall (f :: * -> *) a b. Functor 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 StopMetricStreams

instance Prelude.NFData StopMetricStreams

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

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

instance Core.ToQuery StopMetricStreams where
  toQuery :: StopMetricStreams -> QueryString
toQuery StopMetricStreams' {[Text]
names :: [Text]
$sel:names:StopMetricStreams' :: StopMetricStreams -> [Text]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"StopMetricStreams" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-08-01" :: Prelude.ByteString),
        ByteString
"Names" ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" [Text]
names
      ]

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

-- |
-- Create a value of 'StopMetricStreamsResponse' 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:
--
-- 'httpStatus', 'stopMetricStreamsResponse_httpStatus' - The response's http status code.
newStopMetricStreamsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopMetricStreamsResponse
newStopMetricStreamsResponse :: Int -> StopMetricStreamsResponse
newStopMetricStreamsResponse Int
pHttpStatus_ =
  StopMetricStreamsResponse' :: Int -> StopMetricStreamsResponse
StopMetricStreamsResponse'
    { $sel:httpStatus:StopMetricStreamsResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData StopMetricStreamsResponse