{-# 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 #-}
module Amazonka.SecurityHub.DescribeProducts
(
DescribeProducts (..),
newDescribeProducts,
describeProducts_nextToken,
describeProducts_productArn,
describeProducts_maxResults,
DescribeProductsResponse (..),
newDescribeProductsResponse,
describeProductsResponse_nextToken,
describeProductsResponse_httpStatus,
describeProductsResponse_products,
)
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.SecurityHub.Types
data DescribeProducts = DescribeProducts'
{
DescribeProducts -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
DescribeProducts -> Maybe Text
productArn :: Prelude.Maybe Prelude.Text,
DescribeProducts -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
}
deriving (DescribeProducts -> DescribeProducts -> Bool
(DescribeProducts -> DescribeProducts -> Bool)
-> (DescribeProducts -> DescribeProducts -> Bool)
-> Eq DescribeProducts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeProducts -> DescribeProducts -> Bool
$c/= :: DescribeProducts -> DescribeProducts -> Bool
== :: DescribeProducts -> DescribeProducts -> Bool
$c== :: DescribeProducts -> DescribeProducts -> Bool
Prelude.Eq, ReadPrec [DescribeProducts]
ReadPrec DescribeProducts
Int -> ReadS DescribeProducts
ReadS [DescribeProducts]
(Int -> ReadS DescribeProducts)
-> ReadS [DescribeProducts]
-> ReadPrec DescribeProducts
-> ReadPrec [DescribeProducts]
-> Read DescribeProducts
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeProducts]
$creadListPrec :: ReadPrec [DescribeProducts]
readPrec :: ReadPrec DescribeProducts
$creadPrec :: ReadPrec DescribeProducts
readList :: ReadS [DescribeProducts]
$creadList :: ReadS [DescribeProducts]
readsPrec :: Int -> ReadS DescribeProducts
$creadsPrec :: Int -> ReadS DescribeProducts
Prelude.Read, Int -> DescribeProducts -> ShowS
[DescribeProducts] -> ShowS
DescribeProducts -> String
(Int -> DescribeProducts -> ShowS)
-> (DescribeProducts -> String)
-> ([DescribeProducts] -> ShowS)
-> Show DescribeProducts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeProducts] -> ShowS
$cshowList :: [DescribeProducts] -> ShowS
show :: DescribeProducts -> String
$cshow :: DescribeProducts -> String
showsPrec :: Int -> DescribeProducts -> ShowS
$cshowsPrec :: Int -> DescribeProducts -> ShowS
Prelude.Show, (forall x. DescribeProducts -> Rep DescribeProducts x)
-> (forall x. Rep DescribeProducts x -> DescribeProducts)
-> Generic DescribeProducts
forall x. Rep DescribeProducts x -> DescribeProducts
forall x. DescribeProducts -> Rep DescribeProducts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeProducts x -> DescribeProducts
$cfrom :: forall x. DescribeProducts -> Rep DescribeProducts x
Prelude.Generic)
newDescribeProducts ::
DescribeProducts
newDescribeProducts :: DescribeProducts
newDescribeProducts =
DescribeProducts' :: Maybe Text -> Maybe Text -> Maybe Natural -> DescribeProducts
DescribeProducts'
{ $sel:nextToken:DescribeProducts' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:productArn:DescribeProducts' :: Maybe Text
productArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:maxResults:DescribeProducts' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
}
describeProducts_nextToken :: Lens.Lens' DescribeProducts (Prelude.Maybe Prelude.Text)
describeProducts_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeProducts -> f DescribeProducts
describeProducts_nextToken = (DescribeProducts -> Maybe Text)
-> (DescribeProducts -> Maybe Text -> DescribeProducts)
-> Lens DescribeProducts DescribeProducts (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProducts' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeProducts' :: DescribeProducts -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeProducts
s@DescribeProducts' {} Maybe Text
a -> DescribeProducts
s {$sel:nextToken:DescribeProducts' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeProducts)
describeProducts_productArn :: Lens.Lens' DescribeProducts (Prelude.Maybe Prelude.Text)
describeProducts_productArn :: (Maybe Text -> f (Maybe Text))
-> DescribeProducts -> f DescribeProducts
describeProducts_productArn = (DescribeProducts -> Maybe Text)
-> (DescribeProducts -> Maybe Text -> DescribeProducts)
-> Lens DescribeProducts DescribeProducts (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProducts' {Maybe Text
productArn :: Maybe Text
$sel:productArn:DescribeProducts' :: DescribeProducts -> Maybe Text
productArn} -> Maybe Text
productArn) (\s :: DescribeProducts
s@DescribeProducts' {} Maybe Text
a -> DescribeProducts
s {$sel:productArn:DescribeProducts' :: Maybe Text
productArn = Maybe Text
a} :: DescribeProducts)
describeProducts_maxResults :: Lens.Lens' DescribeProducts (Prelude.Maybe Prelude.Natural)
describeProducts_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> DescribeProducts -> f DescribeProducts
describeProducts_maxResults = (DescribeProducts -> Maybe Natural)
-> (DescribeProducts -> Maybe Natural -> DescribeProducts)
-> Lens
DescribeProducts DescribeProducts (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProducts' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:DescribeProducts' :: DescribeProducts -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: DescribeProducts
s@DescribeProducts' {} Maybe Natural
a -> DescribeProducts
s {$sel:maxResults:DescribeProducts' :: Maybe Natural
maxResults = Maybe Natural
a} :: DescribeProducts)
instance Core.AWSPager DescribeProducts where
page :: DescribeProducts
-> AWSResponse DescribeProducts -> Maybe DescribeProducts
page DescribeProducts
rq AWSResponse DescribeProducts
rs
| Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse DescribeProducts
DescribeProductsResponse
rs
DescribeProductsResponse
-> Getting (First Text) DescribeProductsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeProductsResponse
-> Const (First Text) DescribeProductsResponse
Lens' DescribeProductsResponse (Maybe Text)
describeProductsResponse_nextToken
((Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeProductsResponse
-> Const (First Text) DescribeProductsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeProductsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe DescribeProducts
forall a. Maybe a
Prelude.Nothing
| [Product] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
(AWSResponse DescribeProducts
DescribeProductsResponse
rs DescribeProductsResponse
-> Getting [Product] DescribeProductsResponse [Product]
-> [Product]
forall s a. s -> Getting a s a -> a
Lens.^. Getting [Product] DescribeProductsResponse [Product]
Lens' DescribeProductsResponse [Product]
describeProductsResponse_products) =
Maybe DescribeProducts
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
DescribeProducts -> Maybe DescribeProducts
forall a. a -> Maybe a
Prelude.Just (DescribeProducts -> Maybe DescribeProducts)
-> DescribeProducts -> Maybe DescribeProducts
forall a b. (a -> b) -> a -> b
Prelude.$
DescribeProducts
rq
DescribeProducts
-> (DescribeProducts -> DescribeProducts) -> DescribeProducts
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeProducts -> Identity DescribeProducts
Lens DescribeProducts DescribeProducts (Maybe Text) (Maybe Text)
describeProducts_nextToken
((Maybe Text -> Identity (Maybe Text))
-> DescribeProducts -> Identity DescribeProducts)
-> Maybe Text -> DescribeProducts -> DescribeProducts
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeProducts
DescribeProductsResponse
rs
DescribeProductsResponse
-> Getting (First Text) DescribeProductsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeProductsResponse
-> Const (First Text) DescribeProductsResponse
Lens' DescribeProductsResponse (Maybe Text)
describeProductsResponse_nextToken
((Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeProductsResponse
-> Const (First Text) DescribeProductsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeProductsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest DescribeProducts where
type
AWSResponse DescribeProducts =
DescribeProductsResponse
request :: DescribeProducts -> Request DescribeProducts
request = Service -> DescribeProducts -> Request DescribeProducts
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy DescribeProducts
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeProducts)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse DescribeProducts))
-> Logger
-> Service
-> Proxy DescribeProducts
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeProducts)))
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 Text -> Int -> [Product] -> DescribeProductsResponse
DescribeProductsResponse'
(Maybe Text -> Int -> [Product] -> DescribeProductsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> [Product] -> DescribeProductsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
Either String (Int -> [Product] -> DescribeProductsResponse)
-> Either String Int
-> Either String ([Product] -> DescribeProductsResponse)
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))
Either String ([Product] -> DescribeProductsResponse)
-> Either String [Product]
-> Either String DescribeProductsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [Product])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Products" Either String (Maybe [Product])
-> [Product] -> Either String [Product]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Product]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable DescribeProducts
instance Prelude.NFData DescribeProducts
instance Core.ToHeaders DescribeProducts where
toHeaders :: DescribeProducts -> ResponseHeaders
toHeaders =
ResponseHeaders -> DescribeProducts -> 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.ToPath DescribeProducts where
toPath :: DescribeProducts -> ByteString
toPath = ByteString -> DescribeProducts -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/products"
instance Core.ToQuery DescribeProducts where
toQuery :: DescribeProducts -> QueryString
toQuery DescribeProducts' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
productArn :: Maybe Text
nextToken :: Maybe Text
$sel:maxResults:DescribeProducts' :: DescribeProducts -> Maybe Natural
$sel:productArn:DescribeProducts' :: DescribeProducts -> Maybe Text
$sel:nextToken:DescribeProducts' :: DescribeProducts -> Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"NextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
ByteString
"ProductArn" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
productArn,
ByteString
"MaxResults" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults
]
data DescribeProductsResponse = DescribeProductsResponse'
{
DescribeProductsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
DescribeProductsResponse -> Int
httpStatus :: Prelude.Int,
DescribeProductsResponse -> [Product]
products :: [Product]
}
deriving (DescribeProductsResponse -> DescribeProductsResponse -> Bool
(DescribeProductsResponse -> DescribeProductsResponse -> Bool)
-> (DescribeProductsResponse -> DescribeProductsResponse -> Bool)
-> Eq DescribeProductsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeProductsResponse -> DescribeProductsResponse -> Bool
$c/= :: DescribeProductsResponse -> DescribeProductsResponse -> Bool
== :: DescribeProductsResponse -> DescribeProductsResponse -> Bool
$c== :: DescribeProductsResponse -> DescribeProductsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeProductsResponse]
ReadPrec DescribeProductsResponse
Int -> ReadS DescribeProductsResponse
ReadS [DescribeProductsResponse]
(Int -> ReadS DescribeProductsResponse)
-> ReadS [DescribeProductsResponse]
-> ReadPrec DescribeProductsResponse
-> ReadPrec [DescribeProductsResponse]
-> Read DescribeProductsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeProductsResponse]
$creadListPrec :: ReadPrec [DescribeProductsResponse]
readPrec :: ReadPrec DescribeProductsResponse
$creadPrec :: ReadPrec DescribeProductsResponse
readList :: ReadS [DescribeProductsResponse]
$creadList :: ReadS [DescribeProductsResponse]
readsPrec :: Int -> ReadS DescribeProductsResponse
$creadsPrec :: Int -> ReadS DescribeProductsResponse
Prelude.Read, Int -> DescribeProductsResponse -> ShowS
[DescribeProductsResponse] -> ShowS
DescribeProductsResponse -> String
(Int -> DescribeProductsResponse -> ShowS)
-> (DescribeProductsResponse -> String)
-> ([DescribeProductsResponse] -> ShowS)
-> Show DescribeProductsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeProductsResponse] -> ShowS
$cshowList :: [DescribeProductsResponse] -> ShowS
show :: DescribeProductsResponse -> String
$cshow :: DescribeProductsResponse -> String
showsPrec :: Int -> DescribeProductsResponse -> ShowS
$cshowsPrec :: Int -> DescribeProductsResponse -> ShowS
Prelude.Show, (forall x.
DescribeProductsResponse -> Rep DescribeProductsResponse x)
-> (forall x.
Rep DescribeProductsResponse x -> DescribeProductsResponse)
-> Generic DescribeProductsResponse
forall x.
Rep DescribeProductsResponse x -> DescribeProductsResponse
forall x.
DescribeProductsResponse -> Rep DescribeProductsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeProductsResponse x -> DescribeProductsResponse
$cfrom :: forall x.
DescribeProductsResponse -> Rep DescribeProductsResponse x
Prelude.Generic)
newDescribeProductsResponse ::
Prelude.Int ->
DescribeProductsResponse
newDescribeProductsResponse :: Int -> DescribeProductsResponse
newDescribeProductsResponse Int
pHttpStatus_ =
DescribeProductsResponse' :: Maybe Text -> Int -> [Product] -> DescribeProductsResponse
DescribeProductsResponse'
{ $sel:nextToken:DescribeProductsResponse' :: Maybe Text
nextToken =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DescribeProductsResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:products:DescribeProductsResponse' :: [Product]
products = [Product]
forall a. Monoid a => a
Prelude.mempty
}
describeProductsResponse_nextToken :: Lens.Lens' DescribeProductsResponse (Prelude.Maybe Prelude.Text)
describeProductsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeProductsResponse -> f DescribeProductsResponse
describeProductsResponse_nextToken = (DescribeProductsResponse -> Maybe Text)
-> (DescribeProductsResponse
-> Maybe Text -> DescribeProductsResponse)
-> Lens' DescribeProductsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProductsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeProductsResponse' :: DescribeProductsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeProductsResponse
s@DescribeProductsResponse' {} Maybe Text
a -> DescribeProductsResponse
s {$sel:nextToken:DescribeProductsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeProductsResponse)
describeProductsResponse_httpStatus :: Lens.Lens' DescribeProductsResponse Prelude.Int
describeProductsResponse_httpStatus :: (Int -> f Int)
-> DescribeProductsResponse -> f DescribeProductsResponse
describeProductsResponse_httpStatus = (DescribeProductsResponse -> Int)
-> (DescribeProductsResponse -> Int -> DescribeProductsResponse)
-> Lens DescribeProductsResponse DescribeProductsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProductsResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeProductsResponse' :: DescribeProductsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeProductsResponse
s@DescribeProductsResponse' {} Int
a -> DescribeProductsResponse
s {$sel:httpStatus:DescribeProductsResponse' :: Int
httpStatus = Int
a} :: DescribeProductsResponse)
describeProductsResponse_products :: Lens.Lens' DescribeProductsResponse [Product]
describeProductsResponse_products :: ([Product] -> f [Product])
-> DescribeProductsResponse -> f DescribeProductsResponse
describeProductsResponse_products = (DescribeProductsResponse -> [Product])
-> (DescribeProductsResponse
-> [Product] -> DescribeProductsResponse)
-> Lens' DescribeProductsResponse [Product]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProductsResponse' {[Product]
products :: [Product]
$sel:products:DescribeProductsResponse' :: DescribeProductsResponse -> [Product]
products} -> [Product]
products) (\s :: DescribeProductsResponse
s@DescribeProductsResponse' {} [Product]
a -> DescribeProductsResponse
s {$sel:products:DescribeProductsResponse' :: [Product]
products = [Product]
a} :: DescribeProductsResponse) (([Product] -> f [Product])
-> DescribeProductsResponse -> f DescribeProductsResponse)
-> (([Product] -> f [Product]) -> [Product] -> f [Product])
-> ([Product] -> f [Product])
-> DescribeProductsResponse
-> f DescribeProductsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Product] -> f [Product]) -> [Product] -> f [Product]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Prelude.NFData DescribeProductsResponse