{-# 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.ApplicationInsights.DescribeComponent
-- 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)
--
-- Describes a component and lists the resources that are grouped together
-- in a component.
module Amazonka.ApplicationInsights.DescribeComponent
  ( -- * Creating a Request
    DescribeComponent (..),
    newDescribeComponent,

    -- * Request Lenses
    describeComponent_resourceGroupName,
    describeComponent_componentName,

    -- * Destructuring the Response
    DescribeComponentResponse (..),
    newDescribeComponentResponse,

    -- * Response Lenses
    describeComponentResponse_applicationComponent,
    describeComponentResponse_resourceList,
    describeComponentResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeComponent' smart constructor.
data DescribeComponent = DescribeComponent'
  { -- | The name of the resource group.
    DescribeComponent -> Text
resourceGroupName :: Prelude.Text,
    -- | The name of the component.
    DescribeComponent -> Text
componentName :: Prelude.Text
  }
  deriving (DescribeComponent -> DescribeComponent -> Bool
(DescribeComponent -> DescribeComponent -> Bool)
-> (DescribeComponent -> DescribeComponent -> Bool)
-> Eq DescribeComponent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeComponent -> DescribeComponent -> Bool
$c/= :: DescribeComponent -> DescribeComponent -> Bool
== :: DescribeComponent -> DescribeComponent -> Bool
$c== :: DescribeComponent -> DescribeComponent -> Bool
Prelude.Eq, ReadPrec [DescribeComponent]
ReadPrec DescribeComponent
Int -> ReadS DescribeComponent
ReadS [DescribeComponent]
(Int -> ReadS DescribeComponent)
-> ReadS [DescribeComponent]
-> ReadPrec DescribeComponent
-> ReadPrec [DescribeComponent]
-> Read DescribeComponent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeComponent]
$creadListPrec :: ReadPrec [DescribeComponent]
readPrec :: ReadPrec DescribeComponent
$creadPrec :: ReadPrec DescribeComponent
readList :: ReadS [DescribeComponent]
$creadList :: ReadS [DescribeComponent]
readsPrec :: Int -> ReadS DescribeComponent
$creadsPrec :: Int -> ReadS DescribeComponent
Prelude.Read, Int -> DescribeComponent -> ShowS
[DescribeComponent] -> ShowS
DescribeComponent -> String
(Int -> DescribeComponent -> ShowS)
-> (DescribeComponent -> String)
-> ([DescribeComponent] -> ShowS)
-> Show DescribeComponent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeComponent] -> ShowS
$cshowList :: [DescribeComponent] -> ShowS
show :: DescribeComponent -> String
$cshow :: DescribeComponent -> String
showsPrec :: Int -> DescribeComponent -> ShowS
$cshowsPrec :: Int -> DescribeComponent -> ShowS
Prelude.Show, (forall x. DescribeComponent -> Rep DescribeComponent x)
-> (forall x. Rep DescribeComponent x -> DescribeComponent)
-> Generic DescribeComponent
forall x. Rep DescribeComponent x -> DescribeComponent
forall x. DescribeComponent -> Rep DescribeComponent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeComponent x -> DescribeComponent
$cfrom :: forall x. DescribeComponent -> Rep DescribeComponent x
Prelude.Generic)

-- |
-- Create a value of 'DescribeComponent' 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:
--
-- 'resourceGroupName', 'describeComponent_resourceGroupName' - The name of the resource group.
--
-- 'componentName', 'describeComponent_componentName' - The name of the component.
newDescribeComponent ::
  -- | 'resourceGroupName'
  Prelude.Text ->
  -- | 'componentName'
  Prelude.Text ->
  DescribeComponent
newDescribeComponent :: Text -> Text -> DescribeComponent
newDescribeComponent
  Text
pResourceGroupName_
  Text
pComponentName_ =
    DescribeComponent' :: Text -> Text -> DescribeComponent
DescribeComponent'
      { $sel:resourceGroupName:DescribeComponent' :: Text
resourceGroupName =
          Text
pResourceGroupName_,
        $sel:componentName:DescribeComponent' :: Text
componentName = Text
pComponentName_
      }

-- | The name of the resource group.
describeComponent_resourceGroupName :: Lens.Lens' DescribeComponent Prelude.Text
describeComponent_resourceGroupName :: (Text -> f Text) -> DescribeComponent -> f DescribeComponent
describeComponent_resourceGroupName = (DescribeComponent -> Text)
-> (DescribeComponent -> Text -> DescribeComponent)
-> Lens DescribeComponent DescribeComponent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComponent' {Text
resourceGroupName :: Text
$sel:resourceGroupName:DescribeComponent' :: DescribeComponent -> Text
resourceGroupName} -> Text
resourceGroupName) (\s :: DescribeComponent
s@DescribeComponent' {} Text
a -> DescribeComponent
s {$sel:resourceGroupName:DescribeComponent' :: Text
resourceGroupName = Text
a} :: DescribeComponent)

-- | The name of the component.
describeComponent_componentName :: Lens.Lens' DescribeComponent Prelude.Text
describeComponent_componentName :: (Text -> f Text) -> DescribeComponent -> f DescribeComponent
describeComponent_componentName = (DescribeComponent -> Text)
-> (DescribeComponent -> Text -> DescribeComponent)
-> Lens DescribeComponent DescribeComponent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComponent' {Text
componentName :: Text
$sel:componentName:DescribeComponent' :: DescribeComponent -> Text
componentName} -> Text
componentName) (\s :: DescribeComponent
s@DescribeComponent' {} Text
a -> DescribeComponent
s {$sel:componentName:DescribeComponent' :: Text
componentName = Text
a} :: DescribeComponent)

instance Core.AWSRequest DescribeComponent where
  type
    AWSResponse DescribeComponent =
      DescribeComponentResponse
  request :: DescribeComponent -> Request DescribeComponent
request = Service -> DescribeComponent -> Request DescribeComponent
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeComponent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeComponent)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeComponent))
-> Logger
-> Service
-> Proxy DescribeComponent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeComponent)))
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 ApplicationComponent
-> Maybe [Text] -> Int -> DescribeComponentResponse
DescribeComponentResponse'
            (Maybe ApplicationComponent
 -> Maybe [Text] -> Int -> DescribeComponentResponse)
-> Either String (Maybe ApplicationComponent)
-> Either String (Maybe [Text] -> Int -> DescribeComponentResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ApplicationComponent)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ApplicationComponent")
            Either String (Maybe [Text] -> Int -> DescribeComponentResponse)
-> Either String (Maybe [Text])
-> Either String (Int -> DescribeComponentResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ResourceList" Either String (Maybe (Maybe [Text]))
-> Maybe [Text] -> Either String (Maybe [Text])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DescribeComponentResponse)
-> Either String Int -> Either String DescribeComponentResponse
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 DescribeComponent

instance Prelude.NFData DescribeComponent

instance Core.ToHeaders DescribeComponent where
  toHeaders :: DescribeComponent -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeComponent -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"EC2WindowsBarleyService.DescribeComponent" ::
                          Prelude.ByteString
                      ),
            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 DescribeComponent where
  toJSON :: DescribeComponent -> Value
toJSON DescribeComponent' {Text
componentName :: Text
resourceGroupName :: Text
$sel:componentName:DescribeComponent' :: DescribeComponent -> Text
$sel:resourceGroupName:DescribeComponent' :: DescribeComponent -> 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
"ResourceGroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceGroupName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ComponentName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
componentName)
          ]
      )

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

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

-- | /See:/ 'newDescribeComponentResponse' smart constructor.
data DescribeComponentResponse = DescribeComponentResponse'
  { DescribeComponentResponse -> Maybe ApplicationComponent
applicationComponent :: Prelude.Maybe ApplicationComponent,
    -- | The list of resource ARNs that belong to the component.
    DescribeComponentResponse -> Maybe [Text]
resourceList :: Prelude.Maybe [Prelude.Text],
    -- | The response's http status code.
    DescribeComponentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeComponentResponse -> DescribeComponentResponse -> Bool
(DescribeComponentResponse -> DescribeComponentResponse -> Bool)
-> (DescribeComponentResponse -> DescribeComponentResponse -> Bool)
-> Eq DescribeComponentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeComponentResponse -> DescribeComponentResponse -> Bool
$c/= :: DescribeComponentResponse -> DescribeComponentResponse -> Bool
== :: DescribeComponentResponse -> DescribeComponentResponse -> Bool
$c== :: DescribeComponentResponse -> DescribeComponentResponse -> Bool
Prelude.Eq, ReadPrec [DescribeComponentResponse]
ReadPrec DescribeComponentResponse
Int -> ReadS DescribeComponentResponse
ReadS [DescribeComponentResponse]
(Int -> ReadS DescribeComponentResponse)
-> ReadS [DescribeComponentResponse]
-> ReadPrec DescribeComponentResponse
-> ReadPrec [DescribeComponentResponse]
-> Read DescribeComponentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeComponentResponse]
$creadListPrec :: ReadPrec [DescribeComponentResponse]
readPrec :: ReadPrec DescribeComponentResponse
$creadPrec :: ReadPrec DescribeComponentResponse
readList :: ReadS [DescribeComponentResponse]
$creadList :: ReadS [DescribeComponentResponse]
readsPrec :: Int -> ReadS DescribeComponentResponse
$creadsPrec :: Int -> ReadS DescribeComponentResponse
Prelude.Read, Int -> DescribeComponentResponse -> ShowS
[DescribeComponentResponse] -> ShowS
DescribeComponentResponse -> String
(Int -> DescribeComponentResponse -> ShowS)
-> (DescribeComponentResponse -> String)
-> ([DescribeComponentResponse] -> ShowS)
-> Show DescribeComponentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeComponentResponse] -> ShowS
$cshowList :: [DescribeComponentResponse] -> ShowS
show :: DescribeComponentResponse -> String
$cshow :: DescribeComponentResponse -> String
showsPrec :: Int -> DescribeComponentResponse -> ShowS
$cshowsPrec :: Int -> DescribeComponentResponse -> ShowS
Prelude.Show, (forall x.
 DescribeComponentResponse -> Rep DescribeComponentResponse x)
-> (forall x.
    Rep DescribeComponentResponse x -> DescribeComponentResponse)
-> Generic DescribeComponentResponse
forall x.
Rep DescribeComponentResponse x -> DescribeComponentResponse
forall x.
DescribeComponentResponse -> Rep DescribeComponentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeComponentResponse x -> DescribeComponentResponse
$cfrom :: forall x.
DescribeComponentResponse -> Rep DescribeComponentResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeComponentResponse' 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:
--
-- 'applicationComponent', 'describeComponentResponse_applicationComponent' - Undocumented member.
--
-- 'resourceList', 'describeComponentResponse_resourceList' - The list of resource ARNs that belong to the component.
--
-- 'httpStatus', 'describeComponentResponse_httpStatus' - The response's http status code.
newDescribeComponentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeComponentResponse
newDescribeComponentResponse :: Int -> DescribeComponentResponse
newDescribeComponentResponse Int
pHttpStatus_ =
  DescribeComponentResponse' :: Maybe ApplicationComponent
-> Maybe [Text] -> Int -> DescribeComponentResponse
DescribeComponentResponse'
    { $sel:applicationComponent:DescribeComponentResponse' :: Maybe ApplicationComponent
applicationComponent =
        Maybe ApplicationComponent
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceList:DescribeComponentResponse' :: Maybe [Text]
resourceList = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeComponentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
describeComponentResponse_applicationComponent :: Lens.Lens' DescribeComponentResponse (Prelude.Maybe ApplicationComponent)
describeComponentResponse_applicationComponent :: (Maybe ApplicationComponent -> f (Maybe ApplicationComponent))
-> DescribeComponentResponse -> f DescribeComponentResponse
describeComponentResponse_applicationComponent = (DescribeComponentResponse -> Maybe ApplicationComponent)
-> (DescribeComponentResponse
    -> Maybe ApplicationComponent -> DescribeComponentResponse)
-> Lens
     DescribeComponentResponse
     DescribeComponentResponse
     (Maybe ApplicationComponent)
     (Maybe ApplicationComponent)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComponentResponse' {Maybe ApplicationComponent
applicationComponent :: Maybe ApplicationComponent
$sel:applicationComponent:DescribeComponentResponse' :: DescribeComponentResponse -> Maybe ApplicationComponent
applicationComponent} -> Maybe ApplicationComponent
applicationComponent) (\s :: DescribeComponentResponse
s@DescribeComponentResponse' {} Maybe ApplicationComponent
a -> DescribeComponentResponse
s {$sel:applicationComponent:DescribeComponentResponse' :: Maybe ApplicationComponent
applicationComponent = Maybe ApplicationComponent
a} :: DescribeComponentResponse)

-- | The list of resource ARNs that belong to the component.
describeComponentResponse_resourceList :: Lens.Lens' DescribeComponentResponse (Prelude.Maybe [Prelude.Text])
describeComponentResponse_resourceList :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeComponentResponse -> f DescribeComponentResponse
describeComponentResponse_resourceList = (DescribeComponentResponse -> Maybe [Text])
-> (DescribeComponentResponse
    -> Maybe [Text] -> DescribeComponentResponse)
-> Lens
     DescribeComponentResponse
     DescribeComponentResponse
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComponentResponse' {Maybe [Text]
resourceList :: Maybe [Text]
$sel:resourceList:DescribeComponentResponse' :: DescribeComponentResponse -> Maybe [Text]
resourceList} -> Maybe [Text]
resourceList) (\s :: DescribeComponentResponse
s@DescribeComponentResponse' {} Maybe [Text]
a -> DescribeComponentResponse
s {$sel:resourceList:DescribeComponentResponse' :: Maybe [Text]
resourceList = Maybe [Text]
a} :: DescribeComponentResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeComponentResponse -> f DescribeComponentResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeComponentResponse
-> f DescribeComponentResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [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.
describeComponentResponse_httpStatus :: Lens.Lens' DescribeComponentResponse Prelude.Int
describeComponentResponse_httpStatus :: (Int -> f Int)
-> DescribeComponentResponse -> f DescribeComponentResponse
describeComponentResponse_httpStatus = (DescribeComponentResponse -> Int)
-> (DescribeComponentResponse -> Int -> DescribeComponentResponse)
-> Lens DescribeComponentResponse DescribeComponentResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeComponentResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeComponentResponse' :: DescribeComponentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeComponentResponse
s@DescribeComponentResponse' {} Int
a -> DescribeComponentResponse
s {$sel:httpStatus:DescribeComponentResponse' :: Int
httpStatus = Int
a} :: DescribeComponentResponse)

instance Prelude.NFData DescribeComponentResponse