{-# 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-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 @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 Amazonka.GroundStation.Types
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:/ '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
(CreateDataflowEndpointGroup
 -> CreateDataflowEndpointGroup -> Bool)
-> (CreateDataflowEndpointGroup
    -> CreateDataflowEndpointGroup -> Bool)
-> Eq CreateDataflowEndpointGroup
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]
(Int -> ReadS CreateDataflowEndpointGroup)
-> ReadS [CreateDataflowEndpointGroup]
-> ReadPrec CreateDataflowEndpointGroup
-> ReadPrec [CreateDataflowEndpointGroup]
-> Read 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
(Int -> CreateDataflowEndpointGroup -> ShowS)
-> (CreateDataflowEndpointGroup -> String)
-> ([CreateDataflowEndpointGroup] -> ShowS)
-> Show CreateDataflowEndpointGroup
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.
 CreateDataflowEndpointGroup -> Rep CreateDataflowEndpointGroup x)
-> (forall x.
    Rep CreateDataflowEndpointGroup x -> CreateDataflowEndpointGroup)
-> Generic CreateDataflowEndpointGroup
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' :: Maybe (HashMap Text Text)
-> [EndpointDetails] -> CreateDataflowEndpointGroup
CreateDataflowEndpointGroup'
    { $sel:tags:CreateDataflowEndpointGroup' :: Maybe (HashMap Text Text)
tags =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:endpointDetails:CreateDataflowEndpointGroup' :: [EndpointDetails]
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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateDataflowEndpointGroup -> f CreateDataflowEndpointGroup
createDataflowEndpointGroup_tags = (CreateDataflowEndpointGroup -> Maybe (HashMap Text Text))
-> (CreateDataflowEndpointGroup
    -> Maybe (HashMap Text Text) -> CreateDataflowEndpointGroup)
-> Lens
     CreateDataflowEndpointGroup
     CreateDataflowEndpointGroup
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateDataflowEndpointGroup -> f CreateDataflowEndpointGroup)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateDataflowEndpointGroup
-> f CreateDataflowEndpointGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
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 :: ([EndpointDetails] -> f [EndpointDetails])
-> CreateDataflowEndpointGroup -> f CreateDataflowEndpointGroup
createDataflowEndpointGroup_endpointDetails = (CreateDataflowEndpointGroup -> [EndpointDetails])
-> (CreateDataflowEndpointGroup
    -> [EndpointDetails] -> CreateDataflowEndpointGroup)
-> Lens
     CreateDataflowEndpointGroup
     CreateDataflowEndpointGroup
     [EndpointDetails]
     [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) (([EndpointDetails] -> f [EndpointDetails])
 -> CreateDataflowEndpointGroup -> f CreateDataflowEndpointGroup)
-> (([EndpointDetails] -> f [EndpointDetails])
    -> [EndpointDetails] -> f [EndpointDetails])
-> ([EndpointDetails] -> f [EndpointDetails])
-> CreateDataflowEndpointGroup
-> f CreateDataflowEndpointGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([EndpointDetails] -> f [EndpointDetails])
-> [EndpointDetails] -> f [EndpointDetails]
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 :: CreateDataflowEndpointGroup -> Request CreateDataflowEndpointGroup
request = Service
-> CreateDataflowEndpointGroup
-> Request CreateDataflowEndpointGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateDataflowEndpointGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateDataflowEndpointGroup)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateDataflowEndpointGroup))
-> Logger
-> Service
-> Proxy CreateDataflowEndpointGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateDataflowEndpointGroup)))
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 -> Object -> Either String DataflowEndpointGroupIdResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable CreateDataflowEndpointGroup

instance Prelude.NFData CreateDataflowEndpointGroup

instance Core.ToHeaders CreateDataflowEndpointGroup where
  toHeaders :: CreateDataflowEndpointGroup -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateDataflowEndpointGroup -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"endpointDetails" Text -> [EndpointDetails] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [EndpointDetails]
endpointDetails)
          ]
      )

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

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