{-# 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.MediaLive.CreateInputSecurityGroup
-- 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 Input Security Group
module Amazonka.MediaLive.CreateInputSecurityGroup
  ( -- * Creating a Request
    CreateInputSecurityGroup (..),
    newCreateInputSecurityGroup,

    -- * Request Lenses
    createInputSecurityGroup_tags,
    createInputSecurityGroup_whitelistRules,

    -- * Destructuring the Response
    CreateInputSecurityGroupResponse (..),
    newCreateInputSecurityGroupResponse,

    -- * Response Lenses
    createInputSecurityGroupResponse_securityGroup,
    createInputSecurityGroupResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaLive.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | The IPv4 CIDRs to whitelist for this Input Security Group
--
-- /See:/ 'newCreateInputSecurityGroup' smart constructor.
data CreateInputSecurityGroup = CreateInputSecurityGroup'
  { -- | A collection of key-value pairs.
    CreateInputSecurityGroup -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | List of IPv4 CIDR addresses to whitelist
    CreateInputSecurityGroup -> Maybe [InputWhitelistRuleCidr]
whitelistRules :: Prelude.Maybe [InputWhitelistRuleCidr]
  }
  deriving (CreateInputSecurityGroup -> CreateInputSecurityGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateInputSecurityGroup -> CreateInputSecurityGroup -> Bool
$c/= :: CreateInputSecurityGroup -> CreateInputSecurityGroup -> Bool
== :: CreateInputSecurityGroup -> CreateInputSecurityGroup -> Bool
$c== :: CreateInputSecurityGroup -> CreateInputSecurityGroup -> Bool
Prelude.Eq, ReadPrec [CreateInputSecurityGroup]
ReadPrec CreateInputSecurityGroup
Int -> ReadS CreateInputSecurityGroup
ReadS [CreateInputSecurityGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateInputSecurityGroup]
$creadListPrec :: ReadPrec [CreateInputSecurityGroup]
readPrec :: ReadPrec CreateInputSecurityGroup
$creadPrec :: ReadPrec CreateInputSecurityGroup
readList :: ReadS [CreateInputSecurityGroup]
$creadList :: ReadS [CreateInputSecurityGroup]
readsPrec :: Int -> ReadS CreateInputSecurityGroup
$creadsPrec :: Int -> ReadS CreateInputSecurityGroup
Prelude.Read, Int -> CreateInputSecurityGroup -> ShowS
[CreateInputSecurityGroup] -> ShowS
CreateInputSecurityGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateInputSecurityGroup] -> ShowS
$cshowList :: [CreateInputSecurityGroup] -> ShowS
show :: CreateInputSecurityGroup -> String
$cshow :: CreateInputSecurityGroup -> String
showsPrec :: Int -> CreateInputSecurityGroup -> ShowS
$cshowsPrec :: Int -> CreateInputSecurityGroup -> ShowS
Prelude.Show, forall x.
Rep CreateInputSecurityGroup x -> CreateInputSecurityGroup
forall x.
CreateInputSecurityGroup -> Rep CreateInputSecurityGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateInputSecurityGroup x -> CreateInputSecurityGroup
$cfrom :: forall x.
CreateInputSecurityGroup -> Rep CreateInputSecurityGroup x
Prelude.Generic)

-- |
-- Create a value of 'CreateInputSecurityGroup' 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:
--
-- 'tags', 'createInputSecurityGroup_tags' - A collection of key-value pairs.
--
-- 'whitelistRules', 'createInputSecurityGroup_whitelistRules' - List of IPv4 CIDR addresses to whitelist
newCreateInputSecurityGroup ::
  CreateInputSecurityGroup
newCreateInputSecurityGroup :: CreateInputSecurityGroup
newCreateInputSecurityGroup =
  CreateInputSecurityGroup'
    { $sel:tags:CreateInputSecurityGroup' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:whitelistRules:CreateInputSecurityGroup' :: Maybe [InputWhitelistRuleCidr]
whitelistRules = forall a. Maybe a
Prelude.Nothing
    }

-- | A collection of key-value pairs.
createInputSecurityGroup_tags :: Lens.Lens' CreateInputSecurityGroup (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createInputSecurityGroup_tags :: Lens' CreateInputSecurityGroup (Maybe (HashMap Text Text))
createInputSecurityGroup_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInputSecurityGroup' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateInputSecurityGroup' :: CreateInputSecurityGroup -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateInputSecurityGroup
s@CreateInputSecurityGroup' {} Maybe (HashMap Text Text)
a -> CreateInputSecurityGroup
s {$sel:tags:CreateInputSecurityGroup' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateInputSecurityGroup) 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

-- | List of IPv4 CIDR addresses to whitelist
createInputSecurityGroup_whitelistRules :: Lens.Lens' CreateInputSecurityGroup (Prelude.Maybe [InputWhitelistRuleCidr])
createInputSecurityGroup_whitelistRules :: Lens' CreateInputSecurityGroup (Maybe [InputWhitelistRuleCidr])
createInputSecurityGroup_whitelistRules = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInputSecurityGroup' {Maybe [InputWhitelistRuleCidr]
whitelistRules :: Maybe [InputWhitelistRuleCidr]
$sel:whitelistRules:CreateInputSecurityGroup' :: CreateInputSecurityGroup -> Maybe [InputWhitelistRuleCidr]
whitelistRules} -> Maybe [InputWhitelistRuleCidr]
whitelistRules) (\s :: CreateInputSecurityGroup
s@CreateInputSecurityGroup' {} Maybe [InputWhitelistRuleCidr]
a -> CreateInputSecurityGroup
s {$sel:whitelistRules:CreateInputSecurityGroup' :: Maybe [InputWhitelistRuleCidr]
whitelistRules = Maybe [InputWhitelistRuleCidr]
a} :: CreateInputSecurityGroup) 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 CreateInputSecurityGroup where
  type
    AWSResponse CreateInputSecurityGroup =
      CreateInputSecurityGroupResponse
  request :: (Service -> Service)
-> CreateInputSecurityGroup -> Request CreateInputSecurityGroup
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 CreateInputSecurityGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateInputSecurityGroup)))
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 InputSecurityGroup -> Int -> CreateInputSecurityGroupResponse
CreateInputSecurityGroupResponse'
            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
"securityGroup")
            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 CreateInputSecurityGroup where
  hashWithSalt :: Int -> CreateInputSecurityGroup -> Int
hashWithSalt Int
_salt CreateInputSecurityGroup' {Maybe [InputWhitelistRuleCidr]
Maybe (HashMap Text Text)
whitelistRules :: Maybe [InputWhitelistRuleCidr]
tags :: Maybe (HashMap Text Text)
$sel:whitelistRules:CreateInputSecurityGroup' :: CreateInputSecurityGroup -> Maybe [InputWhitelistRuleCidr]
$sel:tags:CreateInputSecurityGroup' :: CreateInputSecurityGroup -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [InputWhitelistRuleCidr]
whitelistRules

instance Prelude.NFData CreateInputSecurityGroup where
  rnf :: CreateInputSecurityGroup -> ()
rnf CreateInputSecurityGroup' {Maybe [InputWhitelistRuleCidr]
Maybe (HashMap Text Text)
whitelistRules :: Maybe [InputWhitelistRuleCidr]
tags :: Maybe (HashMap Text Text)
$sel:whitelistRules:CreateInputSecurityGroup' :: CreateInputSecurityGroup -> Maybe [InputWhitelistRuleCidr]
$sel:tags:CreateInputSecurityGroup' :: CreateInputSecurityGroup -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [InputWhitelistRuleCidr]
whitelistRules

instance Data.ToHeaders CreateInputSecurityGroup where
  toHeaders :: CreateInputSecurityGroup -> 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 CreateInputSecurityGroup where
  toJSON :: CreateInputSecurityGroup -> Value
toJSON CreateInputSecurityGroup' {Maybe [InputWhitelistRuleCidr]
Maybe (HashMap Text Text)
whitelistRules :: Maybe [InputWhitelistRuleCidr]
tags :: Maybe (HashMap Text Text)
$sel:whitelistRules:CreateInputSecurityGroup' :: CreateInputSecurityGroup -> Maybe [InputWhitelistRuleCidr]
$sel:tags:CreateInputSecurityGroup' :: CreateInputSecurityGroup -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"tags" 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 (HashMap Text Text)
tags,
            (Key
"whitelistRules" 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 [InputWhitelistRuleCidr]
whitelistRules
          ]
      )

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

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

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

-- |
-- Create a value of 'CreateInputSecurityGroupResponse' 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:
--
-- 'securityGroup', 'createInputSecurityGroupResponse_securityGroup' - Undocumented member.
--
-- 'httpStatus', 'createInputSecurityGroupResponse_httpStatus' - The response's http status code.
newCreateInputSecurityGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateInputSecurityGroupResponse
newCreateInputSecurityGroupResponse :: Int -> CreateInputSecurityGroupResponse
newCreateInputSecurityGroupResponse Int
pHttpStatus_ =
  CreateInputSecurityGroupResponse'
    { $sel:securityGroup:CreateInputSecurityGroupResponse' :: Maybe InputSecurityGroup
securityGroup =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateInputSecurityGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
createInputSecurityGroupResponse_securityGroup :: Lens.Lens' CreateInputSecurityGroupResponse (Prelude.Maybe InputSecurityGroup)
createInputSecurityGroupResponse_securityGroup :: Lens' CreateInputSecurityGroupResponse (Maybe InputSecurityGroup)
createInputSecurityGroupResponse_securityGroup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInputSecurityGroupResponse' {Maybe InputSecurityGroup
securityGroup :: Maybe InputSecurityGroup
$sel:securityGroup:CreateInputSecurityGroupResponse' :: CreateInputSecurityGroupResponse -> Maybe InputSecurityGroup
securityGroup} -> Maybe InputSecurityGroup
securityGroup) (\s :: CreateInputSecurityGroupResponse
s@CreateInputSecurityGroupResponse' {} Maybe InputSecurityGroup
a -> CreateInputSecurityGroupResponse
s {$sel:securityGroup:CreateInputSecurityGroupResponse' :: Maybe InputSecurityGroup
securityGroup = Maybe InputSecurityGroup
a} :: CreateInputSecurityGroupResponse)

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

instance
  Prelude.NFData
    CreateInputSecurityGroupResponse
  where
  rnf :: CreateInputSecurityGroupResponse -> ()
rnf CreateInputSecurityGroupResponse' {Int
Maybe InputSecurityGroup
httpStatus :: Int
securityGroup :: Maybe InputSecurityGroup
$sel:httpStatus:CreateInputSecurityGroupResponse' :: CreateInputSecurityGroupResponse -> Int
$sel:securityGroup:CreateInputSecurityGroupResponse' :: CreateInputSecurityGroupResponse -> Maybe InputSecurityGroup
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe InputSecurityGroup
securityGroup
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus