{-# 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.CreateComponent
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a custom component by grouping similar standalone instances to
-- monitor.
module Amazonka.ApplicationInsights.CreateComponent
  ( -- * Creating a Request
    CreateComponent (..),
    newCreateComponent,

    -- * Request Lenses
    createComponent_resourceGroupName,
    createComponent_componentName,
    createComponent_resourceList,

    -- * Destructuring the Response
    CreateComponentResponse (..),
    newCreateComponentResponse,

    -- * Response Lenses
    createComponentResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'CreateComponent' 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', 'createComponent_resourceGroupName' - The name of the resource group.
--
-- 'componentName', 'createComponent_componentName' - The name of the component.
--
-- 'resourceList', 'createComponent_resourceList' - The list of resource ARNs that belong to the component.
newCreateComponent ::
  -- | 'resourceGroupName'
  Prelude.Text ->
  -- | 'componentName'
  Prelude.Text ->
  CreateComponent
newCreateComponent :: Text -> Text -> CreateComponent
newCreateComponent
  Text
pResourceGroupName_
  Text
pComponentName_ =
    CreateComponent'
      { $sel:resourceGroupName:CreateComponent' :: Text
resourceGroupName =
          Text
pResourceGroupName_,
        $sel:componentName:CreateComponent' :: Text
componentName = Text
pComponentName_,
        $sel:resourceList:CreateComponent' :: [Text]
resourceList = forall a. Monoid a => a
Prelude.mempty
      }

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

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

-- | The list of resource ARNs that belong to the component.
createComponent_resourceList :: Lens.Lens' CreateComponent [Prelude.Text]
createComponent_resourceList :: Lens' CreateComponent [Text]
createComponent_resourceList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComponent' {[Text]
resourceList :: [Text]
$sel:resourceList:CreateComponent' :: CreateComponent -> [Text]
resourceList} -> [Text]
resourceList) (\s :: CreateComponent
s@CreateComponent' {} [Text]
a -> CreateComponent
s {$sel:resourceList:CreateComponent' :: [Text]
resourceList = [Text]
a} :: CreateComponent) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateComponent where
  type
    AWSResponse CreateComponent =
      CreateComponentResponse
  request :: (Service -> Service) -> CreateComponent -> Request CreateComponent
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 CreateComponent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateComponent)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CreateComponentResponse
CreateComponentResponse'
            forall (f :: * -> *) a b. Functor 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 CreateComponent where
  hashWithSalt :: Int -> CreateComponent -> Int
hashWithSalt Int
_salt CreateComponent' {[Text]
Text
resourceList :: [Text]
componentName :: Text
resourceGroupName :: Text
$sel:resourceList:CreateComponent' :: CreateComponent -> [Text]
$sel:componentName:CreateComponent' :: CreateComponent -> Text
$sel:resourceGroupName:CreateComponent' :: CreateComponent -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
componentName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
resourceList

instance Prelude.NFData CreateComponent where
  rnf :: CreateComponent -> ()
rnf CreateComponent' {[Text]
Text
resourceList :: [Text]
componentName :: Text
resourceGroupName :: Text
$sel:resourceList:CreateComponent' :: CreateComponent -> [Text]
$sel:componentName:CreateComponent' :: CreateComponent -> Text
$sel:resourceGroupName:CreateComponent' :: CreateComponent -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
resourceGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
componentName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
resourceList

instance Data.ToHeaders CreateComponent where
  toHeaders :: CreateComponent -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"EC2WindowsBarleyService.CreateComponent" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON CreateComponent where
  toJSON :: CreateComponent -> Value
toJSON CreateComponent' {[Text]
Text
resourceList :: [Text]
componentName :: Text
resourceGroupName :: Text
$sel:resourceList:CreateComponent' :: CreateComponent -> [Text]
$sel:componentName:CreateComponent' :: CreateComponent -> Text
$sel:resourceGroupName:CreateComponent' :: CreateComponent -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ResourceGroupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceGroupName),
            forall a. a -> Maybe a
Prelude.Just (Key
"ComponentName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
componentName),
            forall a. a -> Maybe a
Prelude.Just (Key
"ResourceList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
resourceList)
          ]
      )

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

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

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

-- |
-- Create a value of 'CreateComponentResponse' 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:
--
-- 'httpStatus', 'createComponentResponse_httpStatus' - The response's http status code.
newCreateComponentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateComponentResponse
newCreateComponentResponse :: Int -> CreateComponentResponse
newCreateComponentResponse Int
pHttpStatus_ =
  CreateComponentResponse' {$sel:httpStatus:CreateComponentResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData CreateComponentResponse where
  rnf :: CreateComponentResponse -> ()
rnf CreateComponentResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateComponentResponse' :: CreateComponentResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus