{-# 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.RobOMaker.BatchDeleteWorlds
-- 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)
--
-- Deletes one or more worlds in a batch operation.
module Amazonka.RobOMaker.BatchDeleteWorlds
  ( -- * Creating a Request
    BatchDeleteWorlds (..),
    newBatchDeleteWorlds,

    -- * Request Lenses
    batchDeleteWorlds_worlds,

    -- * Destructuring the Response
    BatchDeleteWorldsResponse (..),
    newBatchDeleteWorldsResponse,

    -- * Response Lenses
    batchDeleteWorldsResponse_unprocessedWorlds,
    batchDeleteWorldsResponse_httpStatus,
  )
where

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
import Amazonka.RobOMaker.Types

-- | /See:/ 'newBatchDeleteWorlds' smart constructor.
data BatchDeleteWorlds = BatchDeleteWorlds'
  { -- | A list of Amazon Resource Names (arns) that correspond to worlds to
    -- delete.
    BatchDeleteWorlds -> NonEmpty Text
worlds :: Prelude.NonEmpty Prelude.Text
  }
  deriving (BatchDeleteWorlds -> BatchDeleteWorlds -> Bool
(BatchDeleteWorlds -> BatchDeleteWorlds -> Bool)
-> (BatchDeleteWorlds -> BatchDeleteWorlds -> Bool)
-> Eq BatchDeleteWorlds
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDeleteWorlds -> BatchDeleteWorlds -> Bool
$c/= :: BatchDeleteWorlds -> BatchDeleteWorlds -> Bool
== :: BatchDeleteWorlds -> BatchDeleteWorlds -> Bool
$c== :: BatchDeleteWorlds -> BatchDeleteWorlds -> Bool
Prelude.Eq, ReadPrec [BatchDeleteWorlds]
ReadPrec BatchDeleteWorlds
Int -> ReadS BatchDeleteWorlds
ReadS [BatchDeleteWorlds]
(Int -> ReadS BatchDeleteWorlds)
-> ReadS [BatchDeleteWorlds]
-> ReadPrec BatchDeleteWorlds
-> ReadPrec [BatchDeleteWorlds]
-> Read BatchDeleteWorlds
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchDeleteWorlds]
$creadListPrec :: ReadPrec [BatchDeleteWorlds]
readPrec :: ReadPrec BatchDeleteWorlds
$creadPrec :: ReadPrec BatchDeleteWorlds
readList :: ReadS [BatchDeleteWorlds]
$creadList :: ReadS [BatchDeleteWorlds]
readsPrec :: Int -> ReadS BatchDeleteWorlds
$creadsPrec :: Int -> ReadS BatchDeleteWorlds
Prelude.Read, Int -> BatchDeleteWorlds -> ShowS
[BatchDeleteWorlds] -> ShowS
BatchDeleteWorlds -> String
(Int -> BatchDeleteWorlds -> ShowS)
-> (BatchDeleteWorlds -> String)
-> ([BatchDeleteWorlds] -> ShowS)
-> Show BatchDeleteWorlds
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDeleteWorlds] -> ShowS
$cshowList :: [BatchDeleteWorlds] -> ShowS
show :: BatchDeleteWorlds -> String
$cshow :: BatchDeleteWorlds -> String
showsPrec :: Int -> BatchDeleteWorlds -> ShowS
$cshowsPrec :: Int -> BatchDeleteWorlds -> ShowS
Prelude.Show, (forall x. BatchDeleteWorlds -> Rep BatchDeleteWorlds x)
-> (forall x. Rep BatchDeleteWorlds x -> BatchDeleteWorlds)
-> Generic BatchDeleteWorlds
forall x. Rep BatchDeleteWorlds x -> BatchDeleteWorlds
forall x. BatchDeleteWorlds -> Rep BatchDeleteWorlds x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchDeleteWorlds x -> BatchDeleteWorlds
$cfrom :: forall x. BatchDeleteWorlds -> Rep BatchDeleteWorlds x
Prelude.Generic)

-- |
-- Create a value of 'BatchDeleteWorlds' 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:
--
-- 'worlds', 'batchDeleteWorlds_worlds' - A list of Amazon Resource Names (arns) that correspond to worlds to
-- delete.
newBatchDeleteWorlds ::
  -- | 'worlds'
  Prelude.NonEmpty Prelude.Text ->
  BatchDeleteWorlds
newBatchDeleteWorlds :: NonEmpty Text -> BatchDeleteWorlds
newBatchDeleteWorlds NonEmpty Text
pWorlds_ =
  BatchDeleteWorlds' :: NonEmpty Text -> BatchDeleteWorlds
BatchDeleteWorlds'
    { $sel:worlds:BatchDeleteWorlds' :: NonEmpty Text
worlds =
        Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pWorlds_
    }

-- | A list of Amazon Resource Names (arns) that correspond to worlds to
-- delete.
batchDeleteWorlds_worlds :: Lens.Lens' BatchDeleteWorlds (Prelude.NonEmpty Prelude.Text)
batchDeleteWorlds_worlds :: (NonEmpty Text -> f (NonEmpty Text))
-> BatchDeleteWorlds -> f BatchDeleteWorlds
batchDeleteWorlds_worlds = (BatchDeleteWorlds -> NonEmpty Text)
-> (BatchDeleteWorlds -> NonEmpty Text -> BatchDeleteWorlds)
-> Lens
     BatchDeleteWorlds BatchDeleteWorlds (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDeleteWorlds' {NonEmpty Text
worlds :: NonEmpty Text
$sel:worlds:BatchDeleteWorlds' :: BatchDeleteWorlds -> NonEmpty Text
worlds} -> NonEmpty Text
worlds) (\s :: BatchDeleteWorlds
s@BatchDeleteWorlds' {} NonEmpty Text
a -> BatchDeleteWorlds
s {$sel:worlds:BatchDeleteWorlds' :: NonEmpty Text
worlds = NonEmpty Text
a} :: BatchDeleteWorlds) ((NonEmpty Text -> f (NonEmpty Text))
 -> BatchDeleteWorlds -> f BatchDeleteWorlds)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> BatchDeleteWorlds
-> f BatchDeleteWorlds
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchDeleteWorlds where
  type
    AWSResponse BatchDeleteWorlds =
      BatchDeleteWorldsResponse
  request :: BatchDeleteWorlds -> Request BatchDeleteWorlds
request = Service -> BatchDeleteWorlds -> Request BatchDeleteWorlds
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy BatchDeleteWorlds
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchDeleteWorlds)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse BatchDeleteWorlds))
-> Logger
-> Service
-> Proxy BatchDeleteWorlds
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchDeleteWorlds)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe (NonEmpty Text) -> Int -> BatchDeleteWorldsResponse
BatchDeleteWorldsResponse'
            (Maybe (NonEmpty Text) -> Int -> BatchDeleteWorldsResponse)
-> Either String (Maybe (NonEmpty Text))
-> Either String (Int -> BatchDeleteWorldsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"unprocessedWorlds")
            Either String (Int -> BatchDeleteWorldsResponse)
-> Either String Int -> Either String BatchDeleteWorldsResponse
forall (f :: * -> *) a b. Applicative f => 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 BatchDeleteWorlds

instance Prelude.NFData BatchDeleteWorlds

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

instance Core.ToJSON BatchDeleteWorlds where
  toJSON :: BatchDeleteWorlds -> Value
toJSON BatchDeleteWorlds' {NonEmpty Text
worlds :: NonEmpty Text
$sel:worlds:BatchDeleteWorlds' :: BatchDeleteWorlds -> NonEmpty Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"worlds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
worlds)]
      )

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

instance Core.ToQuery BatchDeleteWorlds where
  toQuery :: BatchDeleteWorlds -> QueryString
toQuery = QueryString -> BatchDeleteWorlds -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newBatchDeleteWorldsResponse' smart constructor.
data BatchDeleteWorldsResponse = BatchDeleteWorldsResponse'
  { -- | A list of unprocessed worlds associated with the call. These worlds were
    -- not deleted.
    BatchDeleteWorldsResponse -> Maybe (NonEmpty Text)
unprocessedWorlds :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The response's http status code.
    BatchDeleteWorldsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchDeleteWorldsResponse -> BatchDeleteWorldsResponse -> Bool
(BatchDeleteWorldsResponse -> BatchDeleteWorldsResponse -> Bool)
-> (BatchDeleteWorldsResponse -> BatchDeleteWorldsResponse -> Bool)
-> Eq BatchDeleteWorldsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDeleteWorldsResponse -> BatchDeleteWorldsResponse -> Bool
$c/= :: BatchDeleteWorldsResponse -> BatchDeleteWorldsResponse -> Bool
== :: BatchDeleteWorldsResponse -> BatchDeleteWorldsResponse -> Bool
$c== :: BatchDeleteWorldsResponse -> BatchDeleteWorldsResponse -> Bool
Prelude.Eq, ReadPrec [BatchDeleteWorldsResponse]
ReadPrec BatchDeleteWorldsResponse
Int -> ReadS BatchDeleteWorldsResponse
ReadS [BatchDeleteWorldsResponse]
(Int -> ReadS BatchDeleteWorldsResponse)
-> ReadS [BatchDeleteWorldsResponse]
-> ReadPrec BatchDeleteWorldsResponse
-> ReadPrec [BatchDeleteWorldsResponse]
-> Read BatchDeleteWorldsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchDeleteWorldsResponse]
$creadListPrec :: ReadPrec [BatchDeleteWorldsResponse]
readPrec :: ReadPrec BatchDeleteWorldsResponse
$creadPrec :: ReadPrec BatchDeleteWorldsResponse
readList :: ReadS [BatchDeleteWorldsResponse]
$creadList :: ReadS [BatchDeleteWorldsResponse]
readsPrec :: Int -> ReadS BatchDeleteWorldsResponse
$creadsPrec :: Int -> ReadS BatchDeleteWorldsResponse
Prelude.Read, Int -> BatchDeleteWorldsResponse -> ShowS
[BatchDeleteWorldsResponse] -> ShowS
BatchDeleteWorldsResponse -> String
(Int -> BatchDeleteWorldsResponse -> ShowS)
-> (BatchDeleteWorldsResponse -> String)
-> ([BatchDeleteWorldsResponse] -> ShowS)
-> Show BatchDeleteWorldsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDeleteWorldsResponse] -> ShowS
$cshowList :: [BatchDeleteWorldsResponse] -> ShowS
show :: BatchDeleteWorldsResponse -> String
$cshow :: BatchDeleteWorldsResponse -> String
showsPrec :: Int -> BatchDeleteWorldsResponse -> ShowS
$cshowsPrec :: Int -> BatchDeleteWorldsResponse -> ShowS
Prelude.Show, (forall x.
 BatchDeleteWorldsResponse -> Rep BatchDeleteWorldsResponse x)
-> (forall x.
    Rep BatchDeleteWorldsResponse x -> BatchDeleteWorldsResponse)
-> Generic BatchDeleteWorldsResponse
forall x.
Rep BatchDeleteWorldsResponse x -> BatchDeleteWorldsResponse
forall x.
BatchDeleteWorldsResponse -> Rep BatchDeleteWorldsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchDeleteWorldsResponse x -> BatchDeleteWorldsResponse
$cfrom :: forall x.
BatchDeleteWorldsResponse -> Rep BatchDeleteWorldsResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchDeleteWorldsResponse' 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:
--
-- 'unprocessedWorlds', 'batchDeleteWorldsResponse_unprocessedWorlds' - A list of unprocessed worlds associated with the call. These worlds were
-- not deleted.
--
-- 'httpStatus', 'batchDeleteWorldsResponse_httpStatus' - The response's http status code.
newBatchDeleteWorldsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchDeleteWorldsResponse
newBatchDeleteWorldsResponse :: Int -> BatchDeleteWorldsResponse
newBatchDeleteWorldsResponse Int
pHttpStatus_ =
  BatchDeleteWorldsResponse' :: Maybe (NonEmpty Text) -> Int -> BatchDeleteWorldsResponse
BatchDeleteWorldsResponse'
    { $sel:unprocessedWorlds:BatchDeleteWorldsResponse' :: Maybe (NonEmpty Text)
unprocessedWorlds =
        Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchDeleteWorldsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of unprocessed worlds associated with the call. These worlds were
-- not deleted.
batchDeleteWorldsResponse_unprocessedWorlds :: Lens.Lens' BatchDeleteWorldsResponse (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
batchDeleteWorldsResponse_unprocessedWorlds :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> BatchDeleteWorldsResponse -> f BatchDeleteWorldsResponse
batchDeleteWorldsResponse_unprocessedWorlds = (BatchDeleteWorldsResponse -> Maybe (NonEmpty Text))
-> (BatchDeleteWorldsResponse
    -> Maybe (NonEmpty Text) -> BatchDeleteWorldsResponse)
-> Lens
     BatchDeleteWorldsResponse
     BatchDeleteWorldsResponse
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDeleteWorldsResponse' {Maybe (NonEmpty Text)
unprocessedWorlds :: Maybe (NonEmpty Text)
$sel:unprocessedWorlds:BatchDeleteWorldsResponse' :: BatchDeleteWorldsResponse -> Maybe (NonEmpty Text)
unprocessedWorlds} -> Maybe (NonEmpty Text)
unprocessedWorlds) (\s :: BatchDeleteWorldsResponse
s@BatchDeleteWorldsResponse' {} Maybe (NonEmpty Text)
a -> BatchDeleteWorldsResponse
s {$sel:unprocessedWorlds:BatchDeleteWorldsResponse' :: Maybe (NonEmpty Text)
unprocessedWorlds = Maybe (NonEmpty Text)
a} :: BatchDeleteWorldsResponse) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> BatchDeleteWorldsResponse -> f BatchDeleteWorldsResponse)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> BatchDeleteWorldsResponse
-> f BatchDeleteWorldsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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 AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData BatchDeleteWorldsResponse