{-# 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.ResourceExplorer2.BatchGetView
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves details about a list of views.
module Amazonka.ResourceExplorer2.BatchGetView
  ( -- * Creating a Request
    BatchGetView (..),
    newBatchGetView,

    -- * Request Lenses
    batchGetView_viewArns,

    -- * Destructuring the Response
    BatchGetViewResponse (..),
    newBatchGetViewResponse,

    -- * Response Lenses
    batchGetViewResponse_errors,
    batchGetViewResponse_views,
    batchGetViewResponse_httpStatus,
  )
where

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 Amazonka.ResourceExplorer2.Types
import qualified Amazonka.Response as Response

-- | /See:/ 'newBatchGetView' smart constructor.
data BatchGetView = BatchGetView'
  { -- | A list of
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon resource names (ARNs)>
    -- that identify the views you want details for.
    BatchGetView -> Maybe (NonEmpty Text)
viewArns :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text)
  }
  deriving (BatchGetView -> BatchGetView -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetView -> BatchGetView -> Bool
$c/= :: BatchGetView -> BatchGetView -> Bool
== :: BatchGetView -> BatchGetView -> Bool
$c== :: BatchGetView -> BatchGetView -> Bool
Prelude.Eq, ReadPrec [BatchGetView]
ReadPrec BatchGetView
Int -> ReadS BatchGetView
ReadS [BatchGetView]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetView]
$creadListPrec :: ReadPrec [BatchGetView]
readPrec :: ReadPrec BatchGetView
$creadPrec :: ReadPrec BatchGetView
readList :: ReadS [BatchGetView]
$creadList :: ReadS [BatchGetView]
readsPrec :: Int -> ReadS BatchGetView
$creadsPrec :: Int -> ReadS BatchGetView
Prelude.Read, Int -> BatchGetView -> ShowS
[BatchGetView] -> ShowS
BatchGetView -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetView] -> ShowS
$cshowList :: [BatchGetView] -> ShowS
show :: BatchGetView -> String
$cshow :: BatchGetView -> String
showsPrec :: Int -> BatchGetView -> ShowS
$cshowsPrec :: Int -> BatchGetView -> ShowS
Prelude.Show, forall x. Rep BatchGetView x -> BatchGetView
forall x. BatchGetView -> Rep BatchGetView x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetView x -> BatchGetView
$cfrom :: forall x. BatchGetView -> Rep BatchGetView x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetView' 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:
--
-- 'viewArns', 'batchGetView_viewArns' - A list of
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon resource names (ARNs)>
-- that identify the views you want details for.
newBatchGetView ::
  BatchGetView
newBatchGetView :: BatchGetView
newBatchGetView =
  BatchGetView' {$sel:viewArns:BatchGetView' :: Maybe (NonEmpty Text)
viewArns = forall a. Maybe a
Prelude.Nothing}

-- | A list of
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon resource names (ARNs)>
-- that identify the views you want details for.
batchGetView_viewArns :: Lens.Lens' BatchGetView (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
batchGetView_viewArns :: Lens' BatchGetView (Maybe (NonEmpty Text))
batchGetView_viewArns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetView' {Maybe (NonEmpty Text)
viewArns :: Maybe (NonEmpty Text)
$sel:viewArns:BatchGetView' :: BatchGetView -> Maybe (NonEmpty Text)
viewArns} -> Maybe (NonEmpty Text)
viewArns) (\s :: BatchGetView
s@BatchGetView' {} Maybe (NonEmpty Text)
a -> BatchGetView
s {$sel:viewArns:BatchGetView' :: Maybe (NonEmpty Text)
viewArns = Maybe (NonEmpty Text)
a} :: BatchGetView) 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 BatchGetView where
  type AWSResponse BatchGetView = BatchGetViewResponse
  request :: (Service -> Service) -> BatchGetView -> Request BatchGetView
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 BatchGetView
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchGetView)))
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 [BatchGetViewError]
-> Maybe [View] -> Int -> BatchGetViewResponse
BatchGetViewResponse'
            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
"Errors" 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
"Views" 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 BatchGetView where
  hashWithSalt :: Int -> BatchGetView -> Int
hashWithSalt Int
_salt BatchGetView' {Maybe (NonEmpty Text)
viewArns :: Maybe (NonEmpty Text)
$sel:viewArns:BatchGetView' :: BatchGetView -> Maybe (NonEmpty Text)
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
viewArns

instance Prelude.NFData BatchGetView where
  rnf :: BatchGetView -> ()
rnf BatchGetView' {Maybe (NonEmpty Text)
viewArns :: Maybe (NonEmpty Text)
$sel:viewArns:BatchGetView' :: BatchGetView -> Maybe (NonEmpty Text)
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
viewArns

instance Data.ToHeaders BatchGetView where
  toHeaders :: BatchGetView -> 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 BatchGetView where
  toJSON :: BatchGetView -> Value
toJSON BatchGetView' {Maybe (NonEmpty Text)
viewArns :: Maybe (NonEmpty Text)
$sel:viewArns:BatchGetView' :: BatchGetView -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"ViewArns" 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 (NonEmpty Text)
viewArns]
      )

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

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

-- | /See:/ 'newBatchGetViewResponse' smart constructor.
data BatchGetViewResponse = BatchGetViewResponse'
  { -- | If any of the specified ARNs result in an error, then this structure
    -- describes the error.
    BatchGetViewResponse -> Maybe [BatchGetViewError]
errors :: Prelude.Maybe [BatchGetViewError],
    -- | A structure with a list of objects with details for each of the
    -- specified views.
    BatchGetViewResponse -> Maybe [View]
views :: Prelude.Maybe [View],
    -- | The response's http status code.
    BatchGetViewResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchGetViewResponse -> BatchGetViewResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetViewResponse -> BatchGetViewResponse -> Bool
$c/= :: BatchGetViewResponse -> BatchGetViewResponse -> Bool
== :: BatchGetViewResponse -> BatchGetViewResponse -> Bool
$c== :: BatchGetViewResponse -> BatchGetViewResponse -> Bool
Prelude.Eq, Int -> BatchGetViewResponse -> ShowS
[BatchGetViewResponse] -> ShowS
BatchGetViewResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetViewResponse] -> ShowS
$cshowList :: [BatchGetViewResponse] -> ShowS
show :: BatchGetViewResponse -> String
$cshow :: BatchGetViewResponse -> String
showsPrec :: Int -> BatchGetViewResponse -> ShowS
$cshowsPrec :: Int -> BatchGetViewResponse -> ShowS
Prelude.Show, forall x. Rep BatchGetViewResponse x -> BatchGetViewResponse
forall x. BatchGetViewResponse -> Rep BatchGetViewResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetViewResponse x -> BatchGetViewResponse
$cfrom :: forall x. BatchGetViewResponse -> Rep BatchGetViewResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetViewResponse' 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:
--
-- 'errors', 'batchGetViewResponse_errors' - If any of the specified ARNs result in an error, then this structure
-- describes the error.
--
-- 'views', 'batchGetViewResponse_views' - A structure with a list of objects with details for each of the
-- specified views.
--
-- 'httpStatus', 'batchGetViewResponse_httpStatus' - The response's http status code.
newBatchGetViewResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchGetViewResponse
newBatchGetViewResponse :: Int -> BatchGetViewResponse
newBatchGetViewResponse Int
pHttpStatus_ =
  BatchGetViewResponse'
    { $sel:errors:BatchGetViewResponse' :: Maybe [BatchGetViewError]
errors = forall a. Maybe a
Prelude.Nothing,
      $sel:views:BatchGetViewResponse' :: Maybe [View]
views = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchGetViewResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If any of the specified ARNs result in an error, then this structure
-- describes the error.
batchGetViewResponse_errors :: Lens.Lens' BatchGetViewResponse (Prelude.Maybe [BatchGetViewError])
batchGetViewResponse_errors :: Lens' BatchGetViewResponse (Maybe [BatchGetViewError])
batchGetViewResponse_errors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetViewResponse' {Maybe [BatchGetViewError]
errors :: Maybe [BatchGetViewError]
$sel:errors:BatchGetViewResponse' :: BatchGetViewResponse -> Maybe [BatchGetViewError]
errors} -> Maybe [BatchGetViewError]
errors) (\s :: BatchGetViewResponse
s@BatchGetViewResponse' {} Maybe [BatchGetViewError]
a -> BatchGetViewResponse
s {$sel:errors:BatchGetViewResponse' :: Maybe [BatchGetViewError]
errors = Maybe [BatchGetViewError]
a} :: BatchGetViewResponse) 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

-- | A structure with a list of objects with details for each of the
-- specified views.
batchGetViewResponse_views :: Lens.Lens' BatchGetViewResponse (Prelude.Maybe [View])
batchGetViewResponse_views :: Lens' BatchGetViewResponse (Maybe [View])
batchGetViewResponse_views = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetViewResponse' {Maybe [View]
views :: Maybe [View]
$sel:views:BatchGetViewResponse' :: BatchGetViewResponse -> Maybe [View]
views} -> Maybe [View]
views) (\s :: BatchGetViewResponse
s@BatchGetViewResponse' {} Maybe [View]
a -> BatchGetViewResponse
s {$sel:views:BatchGetViewResponse' :: Maybe [View]
views = Maybe [View]
a} :: BatchGetViewResponse) 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.
batchGetViewResponse_httpStatus :: Lens.Lens' BatchGetViewResponse Prelude.Int
batchGetViewResponse_httpStatus :: Lens' BatchGetViewResponse Int
batchGetViewResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetViewResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchGetViewResponse' :: BatchGetViewResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchGetViewResponse
s@BatchGetViewResponse' {} Int
a -> BatchGetViewResponse
s {$sel:httpStatus:BatchGetViewResponse' :: Int
httpStatus = Int
a} :: BatchGetViewResponse)

instance Prelude.NFData BatchGetViewResponse where
  rnf :: BatchGetViewResponse -> ()
rnf BatchGetViewResponse' {Int
Maybe [BatchGetViewError]
Maybe [View]
httpStatus :: Int
views :: Maybe [View]
errors :: Maybe [BatchGetViewError]
$sel:httpStatus:BatchGetViewResponse' :: BatchGetViewResponse -> Int
$sel:views:BatchGetViewResponse' :: BatchGetViewResponse -> Maybe [View]
$sel:errors:BatchGetViewResponse' :: BatchGetViewResponse -> Maybe [BatchGetViewError]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [BatchGetViewError]
errors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [View]
views
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus