{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$sel:names:StartMetricStreams' :: [Text]
names = 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 :: Lens' StartMetricStreams [Text]
startMetricStreams_names = 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) 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 StartMetricStreams where
  type
    AWSResponse StartMetricStreams =
      StartMetricStreamsResponse
  request :: (Service -> Service)
-> StartMetricStreams -> Request StartMetricStreams
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 StartMetricStreams
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartMetricStreams)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"StartMetricStreamsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> StartMetricStreamsResponse
StartMetricStreamsResponse'
            forall (f :: * -> *) a b. Functor 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 StartMetricStreams where
  hashWithSalt :: Int -> StartMetricStreams -> Int
hashWithSalt Int
_salt StartMetricStreams' {[Text]
names :: [Text]
$sel:names:StartMetricStreams' :: StartMetricStreams -> [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
names

instance Prelude.NFData StartMetricStreams where
  rnf :: StartMetricStreams -> ()
rnf StartMetricStreams' {[Text]
names :: [Text]
$sel:names:StartMetricStreams' :: StartMetricStreams -> [Text]
..} = forall a. NFData a => a -> ()
Prelude.rnf [Text]
names

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

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

instance Data.ToQuery StartMetricStreams where
  toQuery :: StartMetricStreams -> QueryString
toQuery StartMetricStreams' {[Text]
names :: [Text]
$sel:names:StartMetricStreams' :: StartMetricStreams -> [Text]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"StartMetricStreams" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-08-01" :: Prelude.ByteString),
        ByteString
"Names" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.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
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]
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
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.
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'
    { $sel:httpStatus:StartMetricStreamsResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
startMetricStreamsResponse_httpStatus :: Lens.Lens' StartMetricStreamsResponse Prelude.Int
startMetricStreamsResponse_httpStatus :: Lens' StartMetricStreamsResponse Int
startMetricStreamsResponse_httpStatus = 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 where
  rnf :: StartMetricStreamsResponse -> ()
rnf StartMetricStreamsResponse' {Int
httpStatus :: Int
$sel:httpStatus:StartMetricStreamsResponse' :: StartMetricStreamsResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus