{-# 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.GroundStation.CreateDataflowEndpointGroup
-- 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 @DataflowEndpoint@ group containing the specified list of
-- @DataflowEndpoint@ objects.
--
-- The @name@ field in each endpoint is used in your mission profile
-- @DataflowEndpointConfig@ to specify which endpoints to use during a
-- contact.
--
-- When a contact uses multiple @DataflowEndpointConfig@ objects, each
-- @Config@ must match a @DataflowEndpoint@ in the same group.
module Amazonka.GroundStation.CreateDataflowEndpointGroup
  ( -- * Creating a Request
    CreateDataflowEndpointGroup (..),
    newCreateDataflowEndpointGroup,

    -- * Request Lenses
    createDataflowEndpointGroup_tags,
    createDataflowEndpointGroup_endpointDetails,

    -- * Destructuring the Response
    DataflowEndpointGroupIdResponse (..),
    newDataflowEndpointGroupIdResponse,

    -- * Response Lenses
    dataflowEndpointGroupIdResponse_dataflowEndpointGroupId,
  )
where

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

-- |
--
-- /See:/ 'newCreateDataflowEndpointGroup' smart constructor.
data CreateDataflowEndpointGroup = CreateDataflowEndpointGroup'
  { -- | Tags of a dataflow endpoint group.
    CreateDataflowEndpointGroup -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Endpoint details of each endpoint in the dataflow endpoint group.
    CreateDataflowEndpointGroup -> [EndpointDetails]
endpointDetails :: [EndpointDetails]
  }
  deriving (CreateDataflowEndpointGroup -> CreateDataflowEndpointGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDataflowEndpointGroup -> CreateDataflowEndpointGroup -> Bool
$c/= :: CreateDataflowEndpointGroup -> CreateDataflowEndpointGroup -> Bool
== :: CreateDataflowEndpointGroup -> CreateDataflowEndpointGroup -> Bool
$c== :: CreateDataflowEndpointGroup -> CreateDataflowEndpointGroup -> Bool
Prelude.Eq, ReadPrec [CreateDataflowEndpointGroup]
ReadPrec CreateDataflowEndpointGroup
Int -> ReadS CreateDataflowEndpointGroup
ReadS [CreateDataflowEndpointGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDataflowEndpointGroup]
$creadListPrec :: ReadPrec [CreateDataflowEndpointGroup]
readPrec :: ReadPrec CreateDataflowEndpointGroup
$creadPrec :: ReadPrec CreateDataflowEndpointGroup
readList :: ReadS [CreateDataflowEndpointGroup]
$creadList :: ReadS [CreateDataflowEndpointGroup]
readsPrec :: Int -> ReadS CreateDataflowEndpointGroup
$creadsPrec :: Int -> ReadS CreateDataflowEndpointGroup
Prelude.Read, Int -> CreateDataflowEndpointGroup -> ShowS
[CreateDataflowEndpointGroup] -> ShowS
CreateDataflowEndpointGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDataflowEndpointGroup] -> ShowS
$cshowList :: [CreateDataflowEndpointGroup] -> ShowS
show :: CreateDataflowEndpointGroup -> String
$cshow :: CreateDataflowEndpointGroup -> String
showsPrec :: Int -> CreateDataflowEndpointGroup -> ShowS
$cshowsPrec :: Int -> CreateDataflowEndpointGroup -> ShowS
Prelude.Show, forall x.
Rep CreateDataflowEndpointGroup x -> CreateDataflowEndpointGroup
forall x.
CreateDataflowEndpointGroup -> Rep CreateDataflowEndpointGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDataflowEndpointGroup x -> CreateDataflowEndpointGroup
$cfrom :: forall x.
CreateDataflowEndpointGroup -> Rep CreateDataflowEndpointGroup x
Prelude.Generic)

-- |
-- Create a value of 'CreateDataflowEndpointGroup' 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', 'createDataflowEndpointGroup_tags' - Tags of a dataflow endpoint group.
--
-- 'endpointDetails', 'createDataflowEndpointGroup_endpointDetails' - Endpoint details of each endpoint in the dataflow endpoint group.
newCreateDataflowEndpointGroup ::
  CreateDataflowEndpointGroup
newCreateDataflowEndpointGroup :: CreateDataflowEndpointGroup
newCreateDataflowEndpointGroup =
  CreateDataflowEndpointGroup'
    { $sel:tags:CreateDataflowEndpointGroup' :: Maybe (HashMap Text Text)
tags =
        forall a. Maybe a
Prelude.Nothing,
      $sel:endpointDetails:CreateDataflowEndpointGroup' :: [EndpointDetails]
endpointDetails = forall a. Monoid a => a
Prelude.mempty
    }

-- | Tags of a dataflow endpoint group.
createDataflowEndpointGroup_tags :: Lens.Lens' CreateDataflowEndpointGroup (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createDataflowEndpointGroup_tags :: Lens' CreateDataflowEndpointGroup (Maybe (HashMap Text Text))
createDataflowEndpointGroup_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataflowEndpointGroup' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateDataflowEndpointGroup' :: CreateDataflowEndpointGroup -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateDataflowEndpointGroup
s@CreateDataflowEndpointGroup' {} Maybe (HashMap Text Text)
a -> CreateDataflowEndpointGroup
s {$sel:tags:CreateDataflowEndpointGroup' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateDataflowEndpointGroup) 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

-- | Endpoint details of each endpoint in the dataflow endpoint group.
createDataflowEndpointGroup_endpointDetails :: Lens.Lens' CreateDataflowEndpointGroup [EndpointDetails]
createDataflowEndpointGroup_endpointDetails :: Lens' CreateDataflowEndpointGroup [EndpointDetails]
createDataflowEndpointGroup_endpointDetails = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataflowEndpointGroup' {[EndpointDetails]
endpointDetails :: [EndpointDetails]
$sel:endpointDetails:CreateDataflowEndpointGroup' :: CreateDataflowEndpointGroup -> [EndpointDetails]
endpointDetails} -> [EndpointDetails]
endpointDetails) (\s :: CreateDataflowEndpointGroup
s@CreateDataflowEndpointGroup' {} [EndpointDetails]
a -> CreateDataflowEndpointGroup
s {$sel:endpointDetails:CreateDataflowEndpointGroup' :: [EndpointDetails]
endpointDetails = [EndpointDetails]
a} :: CreateDataflowEndpointGroup) 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 CreateDataflowEndpointGroup where
  type
    AWSResponse CreateDataflowEndpointGroup =
      DataflowEndpointGroupIdResponse
  request :: (Service -> Service)
-> CreateDataflowEndpointGroup
-> Request CreateDataflowEndpointGroup
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 CreateDataflowEndpointGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateDataflowEndpointGroup)))
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 -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable CreateDataflowEndpointGroup where
  hashWithSalt :: Int -> CreateDataflowEndpointGroup -> Int
hashWithSalt Int
_salt CreateDataflowEndpointGroup' {[EndpointDetails]
Maybe (HashMap Text Text)
endpointDetails :: [EndpointDetails]
tags :: Maybe (HashMap Text Text)
$sel:endpointDetails:CreateDataflowEndpointGroup' :: CreateDataflowEndpointGroup -> [EndpointDetails]
$sel:tags:CreateDataflowEndpointGroup' :: CreateDataflowEndpointGroup -> 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` [EndpointDetails]
endpointDetails

instance Prelude.NFData CreateDataflowEndpointGroup where
  rnf :: CreateDataflowEndpointGroup -> ()
rnf CreateDataflowEndpointGroup' {[EndpointDetails]
Maybe (HashMap Text Text)
endpointDetails :: [EndpointDetails]
tags :: Maybe (HashMap Text Text)
$sel:endpointDetails:CreateDataflowEndpointGroup' :: CreateDataflowEndpointGroup -> [EndpointDetails]
$sel:tags:CreateDataflowEndpointGroup' :: CreateDataflowEndpointGroup -> 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 [EndpointDetails]
endpointDetails

instance Data.ToHeaders CreateDataflowEndpointGroup where
  toHeaders :: CreateDataflowEndpointGroup -> 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 CreateDataflowEndpointGroup where
  toJSON :: CreateDataflowEndpointGroup -> Value
toJSON CreateDataflowEndpointGroup' {[EndpointDetails]
Maybe (HashMap Text Text)
endpointDetails :: [EndpointDetails]
tags :: Maybe (HashMap Text Text)
$sel:endpointDetails:CreateDataflowEndpointGroup' :: CreateDataflowEndpointGroup -> [EndpointDetails]
$sel:tags:CreateDataflowEndpointGroup' :: CreateDataflowEndpointGroup -> 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,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"endpointDetails" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [EndpointDetails]
endpointDetails)
          ]
      )

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

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