{-# 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.DirectConnect.ConfirmConnection
-- 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)
--
-- Confirms the creation of the specified hosted connection on an
-- interconnect.
--
-- Upon creation, the hosted connection is initially in the @Ordering@
-- state, and remains in this state until the owner confirms creation of
-- the hosted connection.
module Amazonka.DirectConnect.ConfirmConnection
  ( -- * Creating a Request
    ConfirmConnection (..),
    newConfirmConnection,

    -- * Request Lenses
    confirmConnection_connectionId,

    -- * Destructuring the Response
    ConfirmConnectionResponse (..),
    newConfirmConnectionResponse,

    -- * Response Lenses
    confirmConnectionResponse_connectionState,
    confirmConnectionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DirectConnect.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:/ 'newConfirmConnection' smart constructor.
data ConfirmConnection = ConfirmConnection'
  { -- | The ID of the hosted connection.
    ConfirmConnection -> Text
connectionId :: Prelude.Text
  }
  deriving (ConfirmConnection -> ConfirmConnection -> Bool
(ConfirmConnection -> ConfirmConnection -> Bool)
-> (ConfirmConnection -> ConfirmConnection -> Bool)
-> Eq ConfirmConnection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfirmConnection -> ConfirmConnection -> Bool
$c/= :: ConfirmConnection -> ConfirmConnection -> Bool
== :: ConfirmConnection -> ConfirmConnection -> Bool
$c== :: ConfirmConnection -> ConfirmConnection -> Bool
Prelude.Eq, ReadPrec [ConfirmConnection]
ReadPrec ConfirmConnection
Int -> ReadS ConfirmConnection
ReadS [ConfirmConnection]
(Int -> ReadS ConfirmConnection)
-> ReadS [ConfirmConnection]
-> ReadPrec ConfirmConnection
-> ReadPrec [ConfirmConnection]
-> Read ConfirmConnection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfirmConnection]
$creadListPrec :: ReadPrec [ConfirmConnection]
readPrec :: ReadPrec ConfirmConnection
$creadPrec :: ReadPrec ConfirmConnection
readList :: ReadS [ConfirmConnection]
$creadList :: ReadS [ConfirmConnection]
readsPrec :: Int -> ReadS ConfirmConnection
$creadsPrec :: Int -> ReadS ConfirmConnection
Prelude.Read, Int -> ConfirmConnection -> ShowS
[ConfirmConnection] -> ShowS
ConfirmConnection -> String
(Int -> ConfirmConnection -> ShowS)
-> (ConfirmConnection -> String)
-> ([ConfirmConnection] -> ShowS)
-> Show ConfirmConnection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfirmConnection] -> ShowS
$cshowList :: [ConfirmConnection] -> ShowS
show :: ConfirmConnection -> String
$cshow :: ConfirmConnection -> String
showsPrec :: Int -> ConfirmConnection -> ShowS
$cshowsPrec :: Int -> ConfirmConnection -> ShowS
Prelude.Show, (forall x. ConfirmConnection -> Rep ConfirmConnection x)
-> (forall x. Rep ConfirmConnection x -> ConfirmConnection)
-> Generic ConfirmConnection
forall x. Rep ConfirmConnection x -> ConfirmConnection
forall x. ConfirmConnection -> Rep ConfirmConnection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfirmConnection x -> ConfirmConnection
$cfrom :: forall x. ConfirmConnection -> Rep ConfirmConnection x
Prelude.Generic)

-- |
-- Create a value of 'ConfirmConnection' 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:
--
-- 'connectionId', 'confirmConnection_connectionId' - The ID of the hosted connection.
newConfirmConnection ::
  -- | 'connectionId'
  Prelude.Text ->
  ConfirmConnection
newConfirmConnection :: Text -> ConfirmConnection
newConfirmConnection Text
pConnectionId_ =
  ConfirmConnection' :: Text -> ConfirmConnection
ConfirmConnection' {$sel:connectionId:ConfirmConnection' :: Text
connectionId = Text
pConnectionId_}

-- | The ID of the hosted connection.
confirmConnection_connectionId :: Lens.Lens' ConfirmConnection Prelude.Text
confirmConnection_connectionId :: (Text -> f Text) -> ConfirmConnection -> f ConfirmConnection
confirmConnection_connectionId = (ConfirmConnection -> Text)
-> (ConfirmConnection -> Text -> ConfirmConnection)
-> Lens ConfirmConnection ConfirmConnection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfirmConnection' {Text
connectionId :: Text
$sel:connectionId:ConfirmConnection' :: ConfirmConnection -> Text
connectionId} -> Text
connectionId) (\s :: ConfirmConnection
s@ConfirmConnection' {} Text
a -> ConfirmConnection
s {$sel:connectionId:ConfirmConnection' :: Text
connectionId = Text
a} :: ConfirmConnection)

instance Core.AWSRequest ConfirmConnection where
  type
    AWSResponse ConfirmConnection =
      ConfirmConnectionResponse
  request :: ConfirmConnection -> Request ConfirmConnection
request = Service -> ConfirmConnection -> Request ConfirmConnection
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ConfirmConnection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ConfirmConnection)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ConfirmConnection))
-> Logger
-> Service
-> Proxy ConfirmConnection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ConfirmConnection)))
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 ->
          Maybe ConnectionState -> Int -> ConfirmConnectionResponse
ConfirmConnectionResponse'
            (Maybe ConnectionState -> Int -> ConfirmConnectionResponse)
-> Either String (Maybe ConnectionState)
-> Either String (Int -> ConfirmConnectionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ConnectionState)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"connectionState")
            Either String (Int -> ConfirmConnectionResponse)
-> Either String Int -> Either String ConfirmConnectionResponse
forall (f :: * -> *) a b. Applicative f => 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 ConfirmConnection

instance Prelude.NFData ConfirmConnection

instance Core.ToHeaders ConfirmConnection where
  toHeaders :: ConfirmConnection -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ConfirmConnection -> 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
"OvertureService.ConfirmConnection" ::
                          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 ConfirmConnection where
  toJSON :: ConfirmConnection -> Value
toJSON ConfirmConnection' {Text
connectionId :: Text
$sel:connectionId:ConfirmConnection' :: ConfirmConnection -> 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
"connectionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
connectionId)]
      )

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

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

-- | /See:/ 'newConfirmConnectionResponse' smart constructor.
data ConfirmConnectionResponse = ConfirmConnectionResponse'
  { -- | The state of the connection. The following are the possible values:
    --
    -- -   @ordering@: The initial state of a hosted connection provisioned on
    --     an interconnect. The connection stays in the ordering state until
    --     the owner of the hosted connection confirms or declines the
    --     connection order.
    --
    -- -   @requested@: The initial state of a standard connection. The
    --     connection stays in the requested state until the Letter of
    --     Authorization (LOA) is sent to the customer.
    --
    -- -   @pending@: The connection has been approved and is being
    --     initialized.
    --
    -- -   @available@: The network link is up and the connection is ready for
    --     use.
    --
    -- -   @down@: The network link is down.
    --
    -- -   @deleting@: The connection is being deleted.
    --
    -- -   @deleted@: The connection has been deleted.
    --
    -- -   @rejected@: A hosted connection in the @ordering@ state enters the
    --     @rejected@ state if it is deleted by the customer.
    --
    -- -   @unknown@: The state of the connection is not available.
    ConfirmConnectionResponse -> Maybe ConnectionState
connectionState :: Prelude.Maybe ConnectionState,
    -- | The response's http status code.
    ConfirmConnectionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ConfirmConnectionResponse -> ConfirmConnectionResponse -> Bool
(ConfirmConnectionResponse -> ConfirmConnectionResponse -> Bool)
-> (ConfirmConnectionResponse -> ConfirmConnectionResponse -> Bool)
-> Eq ConfirmConnectionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfirmConnectionResponse -> ConfirmConnectionResponse -> Bool
$c/= :: ConfirmConnectionResponse -> ConfirmConnectionResponse -> Bool
== :: ConfirmConnectionResponse -> ConfirmConnectionResponse -> Bool
$c== :: ConfirmConnectionResponse -> ConfirmConnectionResponse -> Bool
Prelude.Eq, ReadPrec [ConfirmConnectionResponse]
ReadPrec ConfirmConnectionResponse
Int -> ReadS ConfirmConnectionResponse
ReadS [ConfirmConnectionResponse]
(Int -> ReadS ConfirmConnectionResponse)
-> ReadS [ConfirmConnectionResponse]
-> ReadPrec ConfirmConnectionResponse
-> ReadPrec [ConfirmConnectionResponse]
-> Read ConfirmConnectionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfirmConnectionResponse]
$creadListPrec :: ReadPrec [ConfirmConnectionResponse]
readPrec :: ReadPrec ConfirmConnectionResponse
$creadPrec :: ReadPrec ConfirmConnectionResponse
readList :: ReadS [ConfirmConnectionResponse]
$creadList :: ReadS [ConfirmConnectionResponse]
readsPrec :: Int -> ReadS ConfirmConnectionResponse
$creadsPrec :: Int -> ReadS ConfirmConnectionResponse
Prelude.Read, Int -> ConfirmConnectionResponse -> ShowS
[ConfirmConnectionResponse] -> ShowS
ConfirmConnectionResponse -> String
(Int -> ConfirmConnectionResponse -> ShowS)
-> (ConfirmConnectionResponse -> String)
-> ([ConfirmConnectionResponse] -> ShowS)
-> Show ConfirmConnectionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfirmConnectionResponse] -> ShowS
$cshowList :: [ConfirmConnectionResponse] -> ShowS
show :: ConfirmConnectionResponse -> String
$cshow :: ConfirmConnectionResponse -> String
showsPrec :: Int -> ConfirmConnectionResponse -> ShowS
$cshowsPrec :: Int -> ConfirmConnectionResponse -> ShowS
Prelude.Show, (forall x.
 ConfirmConnectionResponse -> Rep ConfirmConnectionResponse x)
-> (forall x.
    Rep ConfirmConnectionResponse x -> ConfirmConnectionResponse)
-> Generic ConfirmConnectionResponse
forall x.
Rep ConfirmConnectionResponse x -> ConfirmConnectionResponse
forall x.
ConfirmConnectionResponse -> Rep ConfirmConnectionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConfirmConnectionResponse x -> ConfirmConnectionResponse
$cfrom :: forall x.
ConfirmConnectionResponse -> Rep ConfirmConnectionResponse x
Prelude.Generic)

-- |
-- Create a value of 'ConfirmConnectionResponse' 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:
--
-- 'connectionState', 'confirmConnectionResponse_connectionState' - The state of the connection. The following are the possible values:
--
-- -   @ordering@: The initial state of a hosted connection provisioned on
--     an interconnect. The connection stays in the ordering state until
--     the owner of the hosted connection confirms or declines the
--     connection order.
--
-- -   @requested@: The initial state of a standard connection. The
--     connection stays in the requested state until the Letter of
--     Authorization (LOA) is sent to the customer.
--
-- -   @pending@: The connection has been approved and is being
--     initialized.
--
-- -   @available@: The network link is up and the connection is ready for
--     use.
--
-- -   @down@: The network link is down.
--
-- -   @deleting@: The connection is being deleted.
--
-- -   @deleted@: The connection has been deleted.
--
-- -   @rejected@: A hosted connection in the @ordering@ state enters the
--     @rejected@ state if it is deleted by the customer.
--
-- -   @unknown@: The state of the connection is not available.
--
-- 'httpStatus', 'confirmConnectionResponse_httpStatus' - The response's http status code.
newConfirmConnectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ConfirmConnectionResponse
newConfirmConnectionResponse :: Int -> ConfirmConnectionResponse
newConfirmConnectionResponse Int
pHttpStatus_ =
  ConfirmConnectionResponse' :: Maybe ConnectionState -> Int -> ConfirmConnectionResponse
ConfirmConnectionResponse'
    { $sel:connectionState:ConfirmConnectionResponse' :: Maybe ConnectionState
connectionState =
        Maybe ConnectionState
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ConfirmConnectionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The state of the connection. The following are the possible values:
--
-- -   @ordering@: The initial state of a hosted connection provisioned on
--     an interconnect. The connection stays in the ordering state until
--     the owner of the hosted connection confirms or declines the
--     connection order.
--
-- -   @requested@: The initial state of a standard connection. The
--     connection stays in the requested state until the Letter of
--     Authorization (LOA) is sent to the customer.
--
-- -   @pending@: The connection has been approved and is being
--     initialized.
--
-- -   @available@: The network link is up and the connection is ready for
--     use.
--
-- -   @down@: The network link is down.
--
-- -   @deleting@: The connection is being deleted.
--
-- -   @deleted@: The connection has been deleted.
--
-- -   @rejected@: A hosted connection in the @ordering@ state enters the
--     @rejected@ state if it is deleted by the customer.
--
-- -   @unknown@: The state of the connection is not available.
confirmConnectionResponse_connectionState :: Lens.Lens' ConfirmConnectionResponse (Prelude.Maybe ConnectionState)
confirmConnectionResponse_connectionState :: (Maybe ConnectionState -> f (Maybe ConnectionState))
-> ConfirmConnectionResponse -> f ConfirmConnectionResponse
confirmConnectionResponse_connectionState = (ConfirmConnectionResponse -> Maybe ConnectionState)
-> (ConfirmConnectionResponse
    -> Maybe ConnectionState -> ConfirmConnectionResponse)
-> Lens
     ConfirmConnectionResponse
     ConfirmConnectionResponse
     (Maybe ConnectionState)
     (Maybe ConnectionState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfirmConnectionResponse' {Maybe ConnectionState
connectionState :: Maybe ConnectionState
$sel:connectionState:ConfirmConnectionResponse' :: ConfirmConnectionResponse -> Maybe ConnectionState
connectionState} -> Maybe ConnectionState
connectionState) (\s :: ConfirmConnectionResponse
s@ConfirmConnectionResponse' {} Maybe ConnectionState
a -> ConfirmConnectionResponse
s {$sel:connectionState:ConfirmConnectionResponse' :: Maybe ConnectionState
connectionState = Maybe ConnectionState
a} :: ConfirmConnectionResponse)

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

instance Prelude.NFData ConfirmConnectionResponse