{-# 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.BatchStart
-- 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 existing resources
module Amazonka.MediaLive.BatchStart
  ( -- * Creating a Request
    BatchStart' (..),
    newBatchStart',

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

    -- * Destructuring the Response
    BatchStartResponse (..),
    newBatchStartResponse,

    -- * Response Lenses
    batchStartResponse_failed,
    batchStartResponse_successful,
    batchStartResponse_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 start resources
--
-- /See:/ 'newBatchStart'' smart constructor.
data BatchStart' = BatchStart''
  { -- | List of channel IDs
    BatchStart' -> Maybe [Text]
channelIds :: Prelude.Maybe [Prelude.Text],
    -- | List of multiplex IDs
    BatchStart' -> Maybe [Text]
multiplexIds :: Prelude.Maybe [Prelude.Text]
  }
  deriving (BatchStart' -> BatchStart' -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchStart' -> BatchStart' -> Bool
$c/= :: BatchStart' -> BatchStart' -> Bool
== :: BatchStart' -> BatchStart' -> Bool
$c== :: BatchStart' -> BatchStart' -> Bool
Prelude.Eq, ReadPrec [BatchStart']
ReadPrec BatchStart'
Int -> ReadS BatchStart'
ReadS [BatchStart']
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchStart']
$creadListPrec :: ReadPrec [BatchStart']
readPrec :: ReadPrec BatchStart'
$creadPrec :: ReadPrec BatchStart'
readList :: ReadS [BatchStart']
$creadList :: ReadS [BatchStart']
readsPrec :: Int -> ReadS BatchStart'
$creadsPrec :: Int -> ReadS BatchStart'
Prelude.Read, Int -> BatchStart' -> ShowS
[BatchStart'] -> ShowS
BatchStart' -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchStart'] -> ShowS
$cshowList :: [BatchStart'] -> ShowS
show :: BatchStart' -> String
$cshow :: BatchStart' -> String
showsPrec :: Int -> BatchStart' -> ShowS
$cshowsPrec :: Int -> BatchStart' -> ShowS
Prelude.Show, forall x. Rep BatchStart' x -> BatchStart'
forall x. BatchStart' -> Rep BatchStart' x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchStart' x -> BatchStart'
$cfrom :: forall x. BatchStart' -> Rep BatchStart' x
Prelude.Generic)

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

-- | List of channel IDs
batchStart'_channelIds :: Lens.Lens' BatchStart' (Prelude.Maybe [Prelude.Text])
batchStart'_channelIds :: Lens' BatchStart' (Maybe [Text])
batchStart'_channelIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStart'' {Maybe [Text]
channelIds :: Maybe [Text]
$sel:channelIds:BatchStart'' :: BatchStart' -> Maybe [Text]
channelIds} -> Maybe [Text]
channelIds) (\s :: BatchStart'
s@BatchStart'' {} Maybe [Text]
a -> BatchStart'
s {$sel:channelIds:BatchStart'' :: Maybe [Text]
channelIds = Maybe [Text]
a} :: BatchStart') 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
batchStart'_multiplexIds :: Lens.Lens' BatchStart' (Prelude.Maybe [Prelude.Text])
batchStart'_multiplexIds :: Lens' BatchStart' (Maybe [Text])
batchStart'_multiplexIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStart'' {Maybe [Text]
multiplexIds :: Maybe [Text]
$sel:multiplexIds:BatchStart'' :: BatchStart' -> Maybe [Text]
multiplexIds} -> Maybe [Text]
multiplexIds) (\s :: BatchStart'
s@BatchStart'' {} Maybe [Text]
a -> BatchStart'
s {$sel:multiplexIds:BatchStart'' :: Maybe [Text]
multiplexIds = Maybe [Text]
a} :: BatchStart') 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 BatchStart' where
  type AWSResponse BatchStart' = BatchStartResponse
  request :: (Service -> Service) -> BatchStart' -> Request BatchStart'
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 BatchStart'
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchStart')))
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 -> BatchStartResponse
BatchStartResponse'
            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 BatchStart' where
  hashWithSalt :: Int -> BatchStart' -> Int
hashWithSalt Int
_salt BatchStart'' {Maybe [Text]
multiplexIds :: Maybe [Text]
channelIds :: Maybe [Text]
$sel:multiplexIds:BatchStart'' :: BatchStart' -> Maybe [Text]
$sel:channelIds:BatchStart'' :: BatchStart' -> 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 BatchStart' where
  rnf :: BatchStart' -> ()
rnf BatchStart'' {Maybe [Text]
multiplexIds :: Maybe [Text]
channelIds :: Maybe [Text]
$sel:multiplexIds:BatchStart'' :: BatchStart' -> Maybe [Text]
$sel:channelIds:BatchStart'' :: BatchStart' -> 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 BatchStart' where
  toHeaders :: BatchStart' -> 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 BatchStart' where
  toJSON :: BatchStart' -> Value
toJSON BatchStart'' {Maybe [Text]
multiplexIds :: Maybe [Text]
channelIds :: Maybe [Text]
$sel:multiplexIds:BatchStart'' :: BatchStart' -> Maybe [Text]
$sel:channelIds:BatchStart'' :: BatchStart' -> 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 BatchStart' where
  toPath :: BatchStart' -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/prod/batch/start"

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

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

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

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

instance Prelude.NFData BatchStartResponse where
  rnf :: BatchStartResponse -> ()
rnf BatchStartResponse' {Int
Maybe [BatchFailedResultModel]
Maybe [BatchSuccessfulResultModel]
httpStatus :: Int
successful :: Maybe [BatchSuccessfulResultModel]
failed :: Maybe [BatchFailedResultModel]
$sel:httpStatus:BatchStartResponse' :: BatchStartResponse -> Int
$sel:successful:BatchStartResponse' :: BatchStartResponse -> Maybe [BatchSuccessfulResultModel]
$sel:failed:BatchStartResponse' :: BatchStartResponse -> 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