{-# 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.MediaLive.BatchStop
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Stops running resources
module Amazonka.MediaLive.BatchStop
  ( -- * Creating a Request
    BatchStop' (..),
    newBatchStop',

    -- * Request Lenses
    batchStop'_channelIds,
    batchStop'_multiplexIds,

    -- * Destructuring the Response
    BatchStopResponse (..),
    newBatchStopResponse,

    -- * Response Lenses
    batchStopResponse_failed,
    batchStopResponse_successful,
    batchStopResponse_httpStatus,
  )
where

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

-- | A request to stop resources
--
-- /See:/ 'newBatchStop'' smart constructor.
data BatchStop' = BatchStop''
  { -- | List of channel IDs
    BatchStop' -> Maybe [Text]
channelIds :: Prelude.Maybe [Prelude.Text],
    -- | List of multiplex IDs
    BatchStop' -> Maybe [Text]
multiplexIds :: Prelude.Maybe [Prelude.Text]
  }
  deriving (BatchStop' -> BatchStop' -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchStop' -> BatchStop' -> Bool
$c/= :: BatchStop' -> BatchStop' -> Bool
== :: BatchStop' -> BatchStop' -> Bool
$c== :: BatchStop' -> BatchStop' -> Bool
Prelude.Eq, ReadPrec [BatchStop']
ReadPrec BatchStop'
Int -> ReadS BatchStop'
ReadS [BatchStop']
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchStop']
$creadListPrec :: ReadPrec [BatchStop']
readPrec :: ReadPrec BatchStop'
$creadPrec :: ReadPrec BatchStop'
readList :: ReadS [BatchStop']
$creadList :: ReadS [BatchStop']
readsPrec :: Int -> ReadS BatchStop'
$creadsPrec :: Int -> ReadS BatchStop'
Prelude.Read, Int -> BatchStop' -> ShowS
[BatchStop'] -> ShowS
BatchStop' -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchStop'] -> ShowS
$cshowList :: [BatchStop'] -> ShowS
show :: BatchStop' -> String
$cshow :: BatchStop' -> String
showsPrec :: Int -> BatchStop' -> ShowS
$cshowsPrec :: Int -> BatchStop' -> ShowS
Prelude.Show, forall x. Rep BatchStop' x -> BatchStop'
forall x. BatchStop' -> Rep BatchStop' x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchStop' x -> BatchStop'
$cfrom :: forall x. BatchStop' -> Rep BatchStop' x
Prelude.Generic)

-- |
-- Create a value of 'BatchStop'' 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:
--
-- 'channelIds', 'batchStop'_channelIds' - List of channel IDs
--
-- 'multiplexIds', 'batchStop'_multiplexIds' - List of multiplex IDs
newBatchStop' ::
  BatchStop'
newBatchStop' :: BatchStop'
newBatchStop' =
  BatchStop''
    { $sel:channelIds:BatchStop'' :: Maybe [Text]
channelIds = forall a. Maybe a
Prelude.Nothing,
      $sel:multiplexIds:BatchStop'' :: Maybe [Text]
multiplexIds = forall a. Maybe a
Prelude.Nothing
    }

-- | List of channel IDs
batchStop'_channelIds :: Lens.Lens' BatchStop' (Prelude.Maybe [Prelude.Text])
batchStop'_channelIds :: Lens' BatchStop' (Maybe [Text])
batchStop'_channelIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStop'' {Maybe [Text]
channelIds :: Maybe [Text]
$sel:channelIds:BatchStop'' :: BatchStop' -> Maybe [Text]
channelIds} -> Maybe [Text]
channelIds) (\s :: BatchStop'
s@BatchStop'' {} Maybe [Text]
a -> BatchStop'
s {$sel:channelIds:BatchStop'' :: Maybe [Text]
channelIds = Maybe [Text]
a} :: BatchStop') 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

-- | List of multiplex IDs
batchStop'_multiplexIds :: Lens.Lens' BatchStop' (Prelude.Maybe [Prelude.Text])
batchStop'_multiplexIds :: Lens' BatchStop' (Maybe [Text])
batchStop'_multiplexIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStop'' {Maybe [Text]
multiplexIds :: Maybe [Text]
$sel:multiplexIds:BatchStop'' :: BatchStop' -> Maybe [Text]
multiplexIds} -> Maybe [Text]
multiplexIds) (\s :: BatchStop'
s@BatchStop'' {} Maybe [Text]
a -> BatchStop'
s {$sel:multiplexIds:BatchStop'' :: Maybe [Text]
multiplexIds = Maybe [Text]
a} :: BatchStop') 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

instance Core.AWSRequest BatchStop' where
  type AWSResponse BatchStop' = BatchStopResponse
  request :: (Service -> Service) -> BatchStop' -> Request BatchStop'
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 BatchStop'
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchStop')))
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 [BatchFailedResultModel]
-> Maybe [BatchSuccessfulResultModel] -> Int -> BatchStopResponse
BatchStopResponse'
            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
"failed" 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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"successful" 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 BatchStop' where
  hashWithSalt :: Int -> BatchStop' -> Int
hashWithSalt Int
_salt BatchStop'' {Maybe [Text]
multiplexIds :: Maybe [Text]
channelIds :: Maybe [Text]
$sel:multiplexIds:BatchStop'' :: BatchStop' -> Maybe [Text]
$sel:channelIds:BatchStop'' :: BatchStop' -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
channelIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
multiplexIds

instance Prelude.NFData BatchStop' where
  rnf :: BatchStop' -> ()
rnf BatchStop'' {Maybe [Text]
multiplexIds :: Maybe [Text]
channelIds :: Maybe [Text]
$sel:multiplexIds:BatchStop'' :: BatchStop' -> Maybe [Text]
$sel:channelIds:BatchStop'' :: BatchStop' -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
channelIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
multiplexIds

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

instance Data.ToJSON BatchStop' where
  toJSON :: BatchStop' -> Value
toJSON BatchStop'' {Maybe [Text]
multiplexIds :: Maybe [Text]
channelIds :: Maybe [Text]
$sel:multiplexIds:BatchStop'' :: BatchStop' -> Maybe [Text]
$sel:channelIds:BatchStop'' :: BatchStop' -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"channelIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
channelIds,
            (Key
"multiplexIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
multiplexIds
          ]
      )

instance Data.ToPath BatchStop' where
  toPath :: BatchStop' -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/prod/batch/stop"

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

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

-- |
-- Create a value of 'BatchStopResponse' 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:
--
-- 'failed', 'batchStopResponse_failed' - List of failed operations
--
-- 'successful', 'batchStopResponse_successful' - List of successful operations
--
-- 'httpStatus', 'batchStopResponse_httpStatus' - The response's http status code.
newBatchStopResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchStopResponse
newBatchStopResponse :: Int -> BatchStopResponse
newBatchStopResponse Int
pHttpStatus_ =
  BatchStopResponse'
    { $sel:failed:BatchStopResponse' :: Maybe [BatchFailedResultModel]
failed = forall a. Maybe a
Prelude.Nothing,
      $sel:successful:BatchStopResponse' :: Maybe [BatchSuccessfulResultModel]
successful = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchStopResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | List of failed operations
batchStopResponse_failed :: Lens.Lens' BatchStopResponse (Prelude.Maybe [BatchFailedResultModel])
batchStopResponse_failed :: Lens' BatchStopResponse (Maybe [BatchFailedResultModel])
batchStopResponse_failed = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStopResponse' {Maybe [BatchFailedResultModel]
failed :: Maybe [BatchFailedResultModel]
$sel:failed:BatchStopResponse' :: BatchStopResponse -> Maybe [BatchFailedResultModel]
failed} -> Maybe [BatchFailedResultModel]
failed) (\s :: BatchStopResponse
s@BatchStopResponse' {} Maybe [BatchFailedResultModel]
a -> BatchStopResponse
s {$sel:failed:BatchStopResponse' :: Maybe [BatchFailedResultModel]
failed = Maybe [BatchFailedResultModel]
a} :: BatchStopResponse) 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

-- | List of successful operations
batchStopResponse_successful :: Lens.Lens' BatchStopResponse (Prelude.Maybe [BatchSuccessfulResultModel])
batchStopResponse_successful :: Lens' BatchStopResponse (Maybe [BatchSuccessfulResultModel])
batchStopResponse_successful = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStopResponse' {Maybe [BatchSuccessfulResultModel]
successful :: Maybe [BatchSuccessfulResultModel]
$sel:successful:BatchStopResponse' :: BatchStopResponse -> Maybe [BatchSuccessfulResultModel]
successful} -> Maybe [BatchSuccessfulResultModel]
successful) (\s :: BatchStopResponse
s@BatchStopResponse' {} Maybe [BatchSuccessfulResultModel]
a -> BatchStopResponse
s {$sel:successful:BatchStopResponse' :: Maybe [BatchSuccessfulResultModel]
successful = Maybe [BatchSuccessfulResultModel]
a} :: BatchStopResponse) 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.
batchStopResponse_httpStatus :: Lens.Lens' BatchStopResponse Prelude.Int
batchStopResponse_httpStatus :: Lens' BatchStopResponse Int
batchStopResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStopResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchStopResponse' :: BatchStopResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchStopResponse
s@BatchStopResponse' {} Int
a -> BatchStopResponse
s {$sel:httpStatus:BatchStopResponse' :: Int
httpStatus = Int
a} :: BatchStopResponse)

instance Prelude.NFData BatchStopResponse where
  rnf :: BatchStopResponse -> ()
rnf BatchStopResponse' {Int
Maybe [BatchFailedResultModel]
Maybe [BatchSuccessfulResultModel]
httpStatus :: Int
successful :: Maybe [BatchSuccessfulResultModel]
failed :: Maybe [BatchFailedResultModel]
$sel:httpStatus:BatchStopResponse' :: BatchStopResponse -> Int
$sel:successful:BatchStopResponse' :: BatchStopResponse -> Maybe [BatchSuccessfulResultModel]
$sel:failed:BatchStopResponse' :: BatchStopResponse -> Maybe [BatchFailedResultModel]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [BatchFailedResultModel]
failed
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [BatchSuccessfulResultModel]
successful
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus