{-# 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.ReserveContact
-- 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)
--
-- Reserves a contact using specified parameters.
module Amazonka.GroundStation.ReserveContact
  ( -- * Creating a Request
    ReserveContact (..),
    newReserveContact,

    -- * Request Lenses
    reserveContact_tags,
    reserveContact_endTime,
    reserveContact_groundStation,
    reserveContact_missionProfileArn,
    reserveContact_satelliteArn,
    reserveContact_startTime,

    -- * Destructuring the Response
    ContactIdResponse (..),
    newContactIdResponse,

    -- * Response Lenses
    contactIdResponse_contactId,
  )
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:/ 'newReserveContact' smart constructor.
data ReserveContact = ReserveContact'
  { -- | Tags assigned to a contact.
    ReserveContact -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | End time of a contact.
    ReserveContact -> POSIX
endTime :: Core.POSIX,
    -- | Name of a ground station.
    ReserveContact -> Text
groundStation :: Prelude.Text,
    -- | ARN of a mission profile.
    ReserveContact -> Text
missionProfileArn :: Prelude.Text,
    -- | ARN of a satellite
    ReserveContact -> Text
satelliteArn :: Prelude.Text,
    -- | Start time of a contact.
    ReserveContact -> POSIX
startTime :: Core.POSIX
  }
  deriving (ReserveContact -> ReserveContact -> Bool
(ReserveContact -> ReserveContact -> Bool)
-> (ReserveContact -> ReserveContact -> Bool) -> Eq ReserveContact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReserveContact -> ReserveContact -> Bool
$c/= :: ReserveContact -> ReserveContact -> Bool
== :: ReserveContact -> ReserveContact -> Bool
$c== :: ReserveContact -> ReserveContact -> Bool
Prelude.Eq, ReadPrec [ReserveContact]
ReadPrec ReserveContact
Int -> ReadS ReserveContact
ReadS [ReserveContact]
(Int -> ReadS ReserveContact)
-> ReadS [ReserveContact]
-> ReadPrec ReserveContact
-> ReadPrec [ReserveContact]
-> Read ReserveContact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReserveContact]
$creadListPrec :: ReadPrec [ReserveContact]
readPrec :: ReadPrec ReserveContact
$creadPrec :: ReadPrec ReserveContact
readList :: ReadS [ReserveContact]
$creadList :: ReadS [ReserveContact]
readsPrec :: Int -> ReadS ReserveContact
$creadsPrec :: Int -> ReadS ReserveContact
Prelude.Read, Int -> ReserveContact -> ShowS
[ReserveContact] -> ShowS
ReserveContact -> String
(Int -> ReserveContact -> ShowS)
-> (ReserveContact -> String)
-> ([ReserveContact] -> ShowS)
-> Show ReserveContact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReserveContact] -> ShowS
$cshowList :: [ReserveContact] -> ShowS
show :: ReserveContact -> String
$cshow :: ReserveContact -> String
showsPrec :: Int -> ReserveContact -> ShowS
$cshowsPrec :: Int -> ReserveContact -> ShowS
Prelude.Show, (forall x. ReserveContact -> Rep ReserveContact x)
-> (forall x. Rep ReserveContact x -> ReserveContact)
-> Generic ReserveContact
forall x. Rep ReserveContact x -> ReserveContact
forall x. ReserveContact -> Rep ReserveContact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReserveContact x -> ReserveContact
$cfrom :: forall x. ReserveContact -> Rep ReserveContact x
Prelude.Generic)

-- |
-- Create a value of 'ReserveContact' 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', 'reserveContact_tags' - Tags assigned to a contact.
--
-- 'endTime', 'reserveContact_endTime' - End time of a contact.
--
-- 'groundStation', 'reserveContact_groundStation' - Name of a ground station.
--
-- 'missionProfileArn', 'reserveContact_missionProfileArn' - ARN of a mission profile.
--
-- 'satelliteArn', 'reserveContact_satelliteArn' - ARN of a satellite
--
-- 'startTime', 'reserveContact_startTime' - Start time of a contact.
newReserveContact ::
  -- | 'endTime'
  Prelude.UTCTime ->
  -- | 'groundStation'
  Prelude.Text ->
  -- | 'missionProfileArn'
  Prelude.Text ->
  -- | 'satelliteArn'
  Prelude.Text ->
  -- | 'startTime'
  Prelude.UTCTime ->
  ReserveContact
newReserveContact :: UTCTime -> Text -> Text -> Text -> UTCTime -> ReserveContact
newReserveContact
  UTCTime
pEndTime_
  Text
pGroundStation_
  Text
pMissionProfileArn_
  Text
pSatelliteArn_
  UTCTime
pStartTime_ =
    ReserveContact' :: Maybe (HashMap Text Text)
-> POSIX -> Text -> Text -> Text -> POSIX -> ReserveContact
ReserveContact'
      { $sel:tags:ReserveContact' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:endTime:ReserveContact' :: POSIX
endTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_,
        $sel:groundStation:ReserveContact' :: Text
groundStation = Text
pGroundStation_,
        $sel:missionProfileArn:ReserveContact' :: Text
missionProfileArn = Text
pMissionProfileArn_,
        $sel:satelliteArn:ReserveContact' :: Text
satelliteArn = Text
pSatelliteArn_,
        $sel:startTime:ReserveContact' :: POSIX
startTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_
      }

-- | Tags assigned to a contact.
reserveContact_tags :: Lens.Lens' ReserveContact (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
reserveContact_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ReserveContact -> f ReserveContact
reserveContact_tags = (ReserveContact -> Maybe (HashMap Text Text))
-> (ReserveContact -> Maybe (HashMap Text Text) -> ReserveContact)
-> Lens
     ReserveContact
     ReserveContact
     (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 (\ReserveContact' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:ReserveContact' :: ReserveContact -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: ReserveContact
s@ReserveContact' {} Maybe (HashMap Text Text)
a -> ReserveContact
s {$sel:tags:ReserveContact' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: ReserveContact) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ReserveContact -> f ReserveContact)
-> ((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)))
-> ReserveContact
-> f ReserveContact
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

-- | End time of a contact.
reserveContact_endTime :: Lens.Lens' ReserveContact Prelude.UTCTime
reserveContact_endTime :: (UTCTime -> f UTCTime) -> ReserveContact -> f ReserveContact
reserveContact_endTime = (ReserveContact -> POSIX)
-> (ReserveContact -> POSIX -> ReserveContact)
-> Lens ReserveContact ReserveContact POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReserveContact' {POSIX
endTime :: POSIX
$sel:endTime:ReserveContact' :: ReserveContact -> POSIX
endTime} -> POSIX
endTime) (\s :: ReserveContact
s@ReserveContact' {} POSIX
a -> ReserveContact
s {$sel:endTime:ReserveContact' :: POSIX
endTime = POSIX
a} :: ReserveContact) ((POSIX -> f POSIX) -> ReserveContact -> f ReserveContact)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ReserveContact
-> f ReserveContact
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Name of a ground station.
reserveContact_groundStation :: Lens.Lens' ReserveContact Prelude.Text
reserveContact_groundStation :: (Text -> f Text) -> ReserveContact -> f ReserveContact
reserveContact_groundStation = (ReserveContact -> Text)
-> (ReserveContact -> Text -> ReserveContact)
-> Lens ReserveContact ReserveContact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReserveContact' {Text
groundStation :: Text
$sel:groundStation:ReserveContact' :: ReserveContact -> Text
groundStation} -> Text
groundStation) (\s :: ReserveContact
s@ReserveContact' {} Text
a -> ReserveContact
s {$sel:groundStation:ReserveContact' :: Text
groundStation = Text
a} :: ReserveContact)

-- | ARN of a mission profile.
reserveContact_missionProfileArn :: Lens.Lens' ReserveContact Prelude.Text
reserveContact_missionProfileArn :: (Text -> f Text) -> ReserveContact -> f ReserveContact
reserveContact_missionProfileArn = (ReserveContact -> Text)
-> (ReserveContact -> Text -> ReserveContact)
-> Lens ReserveContact ReserveContact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReserveContact' {Text
missionProfileArn :: Text
$sel:missionProfileArn:ReserveContact' :: ReserveContact -> Text
missionProfileArn} -> Text
missionProfileArn) (\s :: ReserveContact
s@ReserveContact' {} Text
a -> ReserveContact
s {$sel:missionProfileArn:ReserveContact' :: Text
missionProfileArn = Text
a} :: ReserveContact)

-- | ARN of a satellite
reserveContact_satelliteArn :: Lens.Lens' ReserveContact Prelude.Text
reserveContact_satelliteArn :: (Text -> f Text) -> ReserveContact -> f ReserveContact
reserveContact_satelliteArn = (ReserveContact -> Text)
-> (ReserveContact -> Text -> ReserveContact)
-> Lens ReserveContact ReserveContact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReserveContact' {Text
satelliteArn :: Text
$sel:satelliteArn:ReserveContact' :: ReserveContact -> Text
satelliteArn} -> Text
satelliteArn) (\s :: ReserveContact
s@ReserveContact' {} Text
a -> ReserveContact
s {$sel:satelliteArn:ReserveContact' :: Text
satelliteArn = Text
a} :: ReserveContact)

-- | Start time of a contact.
reserveContact_startTime :: Lens.Lens' ReserveContact Prelude.UTCTime
reserveContact_startTime :: (UTCTime -> f UTCTime) -> ReserveContact -> f ReserveContact
reserveContact_startTime = (ReserveContact -> POSIX)
-> (ReserveContact -> POSIX -> ReserveContact)
-> Lens ReserveContact ReserveContact POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReserveContact' {POSIX
startTime :: POSIX
$sel:startTime:ReserveContact' :: ReserveContact -> POSIX
startTime} -> POSIX
startTime) (\s :: ReserveContact
s@ReserveContact' {} POSIX
a -> ReserveContact
s {$sel:startTime:ReserveContact' :: POSIX
startTime = POSIX
a} :: ReserveContact) ((POSIX -> f POSIX) -> ReserveContact -> f ReserveContact)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ReserveContact
-> f ReserveContact
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.AWSRequest ReserveContact where
  type AWSResponse ReserveContact = ContactIdResponse
  request :: ReserveContact -> Request ReserveContact
request = Service -> ReserveContact -> Request ReserveContact
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ReserveContact
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ReserveContact)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ReserveContact))
-> Logger
-> Service
-> Proxy ReserveContact
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ReserveContact)))
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 ContactIdResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable ReserveContact

instance Prelude.NFData ReserveContact

instance Core.ToHeaders ReserveContact where
  toHeaders :: ReserveContact -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ReserveContact -> 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 ReserveContact where
  toJSON :: ReserveContact -> Value
toJSON ReserveContact' {Maybe (HashMap Text Text)
Text
POSIX
startTime :: POSIX
satelliteArn :: Text
missionProfileArn :: Text
groundStation :: Text
endTime :: POSIX
tags :: Maybe (HashMap Text Text)
$sel:startTime:ReserveContact' :: ReserveContact -> POSIX
$sel:satelliteArn:ReserveContact' :: ReserveContact -> Text
$sel:missionProfileArn:ReserveContact' :: ReserveContact -> Text
$sel:groundStation:ReserveContact' :: ReserveContact -> Text
$sel:endTime:ReserveContact' :: ReserveContact -> POSIX
$sel:tags:ReserveContact' :: ReserveContact -> 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
"endTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
endTime),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"groundStation" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
groundStation),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"missionProfileArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
missionProfileArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"satelliteArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
satelliteArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"startTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
startTime)
          ]
      )

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

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