{-# 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-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)
--
-- 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.Lens as Lens
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
(CreateComponent -> CreateComponent -> Bool)
-> (CreateComponent -> CreateComponent -> Bool)
-> Eq CreateComponent
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]
(Int -> ReadS CreateComponent)
-> ReadS [CreateComponent]
-> ReadPrec CreateComponent
-> ReadPrec [CreateComponent]
-> Read 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
(Int -> CreateComponent -> ShowS)
-> (CreateComponent -> String)
-> ([CreateComponent] -> ShowS)
-> Show CreateComponent
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. CreateComponent -> Rep CreateComponent x)
-> (forall x. Rep CreateComponent x -> CreateComponent)
-> Generic CreateComponent
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' :: Text -> Text -> [Text] -> CreateComponent
CreateComponent'
      { $sel:resourceGroupName:CreateComponent' :: Text
resourceGroupName =
          Text
pResourceGroupName_,
        $sel:componentName:CreateComponent' :: Text
componentName = Text
pComponentName_,
        $sel:resourceList:CreateComponent' :: [Text]
resourceList = [Text]
forall a. Monoid a => a
Prelude.mempty
      }

-- | The name of the resource group.
createComponent_resourceGroupName :: Lens.Lens' CreateComponent Prelude.Text
createComponent_resourceGroupName :: (Text -> f Text) -> CreateComponent -> f CreateComponent
createComponent_resourceGroupName = (CreateComponent -> Text)
-> (CreateComponent -> Text -> CreateComponent)
-> Lens CreateComponent CreateComponent Text Text
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 :: (Text -> f Text) -> CreateComponent -> f CreateComponent
createComponent_componentName = (CreateComponent -> Text)
-> (CreateComponent -> Text -> CreateComponent)
-> Lens CreateComponent CreateComponent Text Text
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 :: ([Text] -> f [Text]) -> CreateComponent -> f CreateComponent
createComponent_resourceList = (CreateComponent -> [Text])
-> (CreateComponent -> [Text] -> CreateComponent)
-> Lens CreateComponent CreateComponent [Text] [Text]
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) (([Text] -> f [Text]) -> CreateComponent -> f CreateComponent)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> CreateComponent
-> f CreateComponent
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
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 :: CreateComponent -> Request CreateComponent
request = Service -> CreateComponent -> Request CreateComponent
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateComponent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateComponent)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse CreateComponent))
-> Logger
-> Service
-> Proxy CreateComponent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateComponent)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CreateComponentResponse
CreateComponentResponse'
            (Int -> CreateComponentResponse)
-> Either String Int -> Either String CreateComponentResponse
forall (f :: * -> *) a b. Functor 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 CreateComponent

instance Prelude.NFData CreateComponent

instance Core.ToHeaders CreateComponent where
  toHeaders :: CreateComponent -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateComponent -> 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.CreateComponent" ::
                          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 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
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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ResourceList" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
resourceList)
          ]
      )

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

instance Core.ToQuery CreateComponent where
  toQuery :: CreateComponent -> QueryString
toQuery = QueryString -> CreateComponent -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(CreateComponentResponse -> CreateComponentResponse -> Bool)
-> (CreateComponentResponse -> CreateComponentResponse -> Bool)
-> Eq CreateComponentResponse
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]
(Int -> ReadS CreateComponentResponse)
-> ReadS [CreateComponentResponse]
-> ReadPrec CreateComponentResponse
-> ReadPrec [CreateComponentResponse]
-> Read 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
(Int -> CreateComponentResponse -> ShowS)
-> (CreateComponentResponse -> String)
-> ([CreateComponentResponse] -> ShowS)
-> Show CreateComponentResponse
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.
 CreateComponentResponse -> Rep CreateComponentResponse x)
-> (forall x.
    Rep CreateComponentResponse x -> CreateComponentResponse)
-> Generic CreateComponentResponse
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' :: Int -> CreateComponentResponse
CreateComponentResponse' {$sel:httpStatus:CreateComponentResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
createComponentResponse_httpStatus :: Lens.Lens' CreateComponentResponse Prelude.Int
createComponentResponse_httpStatus :: (Int -> f Int)
-> CreateComponentResponse -> f CreateComponentResponse
createComponentResponse_httpStatus = (CreateComponentResponse -> Int)
-> (CreateComponentResponse -> Int -> CreateComponentResponse)
-> Lens CreateComponentResponse CreateComponentResponse Int Int
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