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

    -- * Request Lenses
    startMetricStreams_names,

    -- * Destructuring the Response
    StartMetricStreamsResponse (..),
    newStartMetricStreamsResponse,

    -- * Response Lenses
    startMetricStreamsResponse_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:/ 'newStartMetricStreams' smart constructor.
data StartMetricStreams = StartMetricStreams'
  { -- | The array of the names of metric streams to start 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 start streaming.
    StartMetricStreams -> [Text]
names :: [Prelude.Text]
  }
  deriving (StartMetricStreams -> StartMetricStreams -> Bool
(StartMetricStreams -> StartMetricStreams -> Bool)
-> (StartMetricStreams -> StartMetricStreams -> Bool)
-> Eq StartMetricStreams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartMetricStreams -> StartMetricStreams -> Bool
$c/= :: StartMetricStreams -> StartMetricStreams -> Bool
== :: StartMetricStreams -> StartMetricStreams -> Bool
$c== :: StartMetricStreams -> StartMetricStreams -> Bool
Prelude.Eq, ReadPrec [StartMetricStreams]
ReadPrec StartMetricStreams
Int -> ReadS StartMetricStreams
ReadS [StartMetricStreams]
(Int -> ReadS StartMetricStreams)
-> ReadS [StartMetricStreams]
-> ReadPrec StartMetricStreams
-> ReadPrec [StartMetricStreams]
-> Read StartMetricStreams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartMetricStreams]
$creadListPrec :: ReadPrec [StartMetricStreams]
readPrec :: ReadPrec StartMetricStreams
$creadPrec :: ReadPrec StartMetricStreams
readList :: ReadS [StartMetricStreams]
$creadList :: ReadS [StartMetricStreams]
readsPrec :: Int -> ReadS StartMetricStreams
$creadsPrec :: Int -> ReadS StartMetricStreams
Prelude.Read, Int -> StartMetricStreams -> ShowS
[StartMetricStreams] -> ShowS
StartMetricStreams -> String
(Int -> StartMetricStreams -> ShowS)
-> (StartMetricStreams -> String)
-> ([StartMetricStreams] -> ShowS)
-> Show StartMetricStreams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartMetricStreams] -> ShowS
$cshowList :: [StartMetricStreams] -> ShowS
show :: StartMetricStreams -> String
$cshow :: StartMetricStreams -> String
showsPrec :: Int -> StartMetricStreams -> ShowS
$cshowsPrec :: Int -> StartMetricStreams -> ShowS
Prelude.Show, (forall x. StartMetricStreams -> Rep StartMetricStreams x)
-> (forall x. Rep StartMetricStreams x -> StartMetricStreams)
-> Generic StartMetricStreams
forall x. Rep StartMetricStreams x -> StartMetricStreams
forall x. StartMetricStreams -> Rep StartMetricStreams x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartMetricStreams x -> StartMetricStreams
$cfrom :: forall x. StartMetricStreams -> Rep StartMetricStreams x
Prelude.Generic)

-- |
-- Create a value of 'StartMetricStreams' 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', 'startMetricStreams_names' - The array of the names of metric streams to start 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 start streaming.
newStartMetricStreams ::
  StartMetricStreams
newStartMetricStreams :: StartMetricStreams
newStartMetricStreams =
  StartMetricStreams' :: [Text] -> StartMetricStreams
StartMetricStreams' {$sel:names:StartMetricStreams' :: [Text]
names = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | The array of the names of metric streams to start 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 start streaming.
startMetricStreams_names :: Lens.Lens' StartMetricStreams [Prelude.Text]
startMetricStreams_names :: ([Text] -> f [Text]) -> StartMetricStreams -> f StartMetricStreams
startMetricStreams_names = (StartMetricStreams -> [Text])
-> (StartMetricStreams -> [Text] -> StartMetricStreams)
-> Lens StartMetricStreams StartMetricStreams [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartMetricStreams' {[Text]
names :: [Text]
$sel:names:StartMetricStreams' :: StartMetricStreams -> [Text]
names} -> [Text]
names) (\s :: StartMetricStreams
s@StartMetricStreams' {} [Text]
a -> StartMetricStreams
s {$sel:names:StartMetricStreams' :: [Text]
names = [Text]
a} :: StartMetricStreams) (([Text] -> f [Text])
 -> StartMetricStreams -> f StartMetricStreams)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> StartMetricStreams
-> f StartMetricStreams
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 StartMetricStreams where
  type
    AWSResponse StartMetricStreams =
      StartMetricStreamsResponse
  request :: StartMetricStreams -> Request StartMetricStreams
request = Service -> StartMetricStreams -> Request StartMetricStreams
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy StartMetricStreams
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartMetricStreams)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse StartMetricStreams))
-> Logger
-> Service
-> Proxy StartMetricStreams
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartMetricStreams)))
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
"StartMetricStreamsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> StartMetricStreamsResponse
StartMetricStreamsResponse'
            (Int -> StartMetricStreamsResponse)
-> Either String Int -> Either String StartMetricStreamsResponse
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 StartMetricStreams

instance Prelude.NFData StartMetricStreams

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

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

instance Core.ToQuery StartMetricStreams where
  toQuery :: StartMetricStreams -> QueryString
toQuery StartMetricStreams' {[Text]
names :: [Text]
$sel:names:StartMetricStreams' :: StartMetricStreams -> [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
"StartMetricStreams" :: 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:/ 'newStartMetricStreamsResponse' smart constructor.
data StartMetricStreamsResponse = StartMetricStreamsResponse'
  { -- | The response's http status code.
    StartMetricStreamsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartMetricStreamsResponse -> StartMetricStreamsResponse -> Bool
(StartMetricStreamsResponse -> StartMetricStreamsResponse -> Bool)
-> (StartMetricStreamsResponse
    -> StartMetricStreamsResponse -> Bool)
-> Eq StartMetricStreamsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartMetricStreamsResponse -> StartMetricStreamsResponse -> Bool
$c/= :: StartMetricStreamsResponse -> StartMetricStreamsResponse -> Bool
== :: StartMetricStreamsResponse -> StartMetricStreamsResponse -> Bool
$c== :: StartMetricStreamsResponse -> StartMetricStreamsResponse -> Bool
Prelude.Eq, ReadPrec [StartMetricStreamsResponse]
ReadPrec StartMetricStreamsResponse
Int -> ReadS StartMetricStreamsResponse
ReadS [StartMetricStreamsResponse]
(Int -> ReadS StartMetricStreamsResponse)
-> ReadS [StartMetricStreamsResponse]
-> ReadPrec StartMetricStreamsResponse
-> ReadPrec [StartMetricStreamsResponse]
-> Read StartMetricStreamsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartMetricStreamsResponse]
$creadListPrec :: ReadPrec [StartMetricStreamsResponse]
readPrec :: ReadPrec StartMetricStreamsResponse
$creadPrec :: ReadPrec StartMetricStreamsResponse
readList :: ReadS [StartMetricStreamsResponse]
$creadList :: ReadS [StartMetricStreamsResponse]
readsPrec :: Int -> ReadS StartMetricStreamsResponse
$creadsPrec :: Int -> ReadS StartMetricStreamsResponse
Prelude.Read, Int -> StartMetricStreamsResponse -> ShowS
[StartMetricStreamsResponse] -> ShowS
StartMetricStreamsResponse -> String
(Int -> StartMetricStreamsResponse -> ShowS)
-> (StartMetricStreamsResponse -> String)
-> ([StartMetricStreamsResponse] -> ShowS)
-> Show StartMetricStreamsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartMetricStreamsResponse] -> ShowS
$cshowList :: [StartMetricStreamsResponse] -> ShowS
show :: StartMetricStreamsResponse -> String
$cshow :: StartMetricStreamsResponse -> String
showsPrec :: Int -> StartMetricStreamsResponse -> ShowS
$cshowsPrec :: Int -> StartMetricStreamsResponse -> ShowS
Prelude.Show, (forall x.
 StartMetricStreamsResponse -> Rep StartMetricStreamsResponse x)
-> (forall x.
    Rep StartMetricStreamsResponse x -> StartMetricStreamsResponse)
-> Generic StartMetricStreamsResponse
forall x.
Rep StartMetricStreamsResponse x -> StartMetricStreamsResponse
forall x.
StartMetricStreamsResponse -> Rep StartMetricStreamsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartMetricStreamsResponse x -> StartMetricStreamsResponse
$cfrom :: forall x.
StartMetricStreamsResponse -> Rep StartMetricStreamsResponse x
Prelude.Generic)

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

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

instance Prelude.NFData StartMetricStreamsResponse