{-# 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.DescribeLoa
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets the LOA-CFA for a connection, interconnect, or link aggregation
-- group (LAG).
--
-- The Letter of Authorization - Connecting Facility Assignment (LOA-CFA)
-- is a document that is used when establishing your cross connect to
-- Amazon Web Services at the colocation facility. For more information,
-- see
-- <https://docs.aws.amazon.com/directconnect/latest/UserGuide/Colocation.html Requesting Cross Connects at Direct Connect Locations>
-- in the /Direct Connect User Guide/.
module Amazonka.DirectConnect.DescribeLoa
  ( -- * Creating a Request
    DescribeLoa (..),
    newDescribeLoa,

    -- * Request Lenses
    describeLoa_loaContentType,
    describeLoa_providerName,
    describeLoa_connectionId,

    -- * Destructuring the Response
    DescribeLoaResponse (..),
    newDescribeLoaResponse,

    -- * Response Lenses
    describeLoaResponse_loaContent,
    describeLoaResponse_loaContentType,
    describeLoaResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeLoa' smart constructor.
data DescribeLoa = DescribeLoa'
  { -- | The standard media type for the LOA-CFA document. The only supported
    -- value is application\/pdf.
    DescribeLoa -> Maybe LoaContentType
loaContentType :: Prelude.Maybe LoaContentType,
    -- | The name of the service provider who establishes connectivity on your
    -- behalf. If you specify this parameter, the LOA-CFA lists the provider
    -- name alongside your company name as the requester of the cross connect.
    DescribeLoa -> Maybe Text
providerName :: Prelude.Maybe Prelude.Text,
    -- | The ID of a connection, LAG, or interconnect.
    DescribeLoa -> Text
connectionId :: Prelude.Text
  }
  deriving (DescribeLoa -> DescribeLoa -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLoa -> DescribeLoa -> Bool
$c/= :: DescribeLoa -> DescribeLoa -> Bool
== :: DescribeLoa -> DescribeLoa -> Bool
$c== :: DescribeLoa -> DescribeLoa -> Bool
Prelude.Eq, ReadPrec [DescribeLoa]
ReadPrec DescribeLoa
Int -> ReadS DescribeLoa
ReadS [DescribeLoa]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLoa]
$creadListPrec :: ReadPrec [DescribeLoa]
readPrec :: ReadPrec DescribeLoa
$creadPrec :: ReadPrec DescribeLoa
readList :: ReadS [DescribeLoa]
$creadList :: ReadS [DescribeLoa]
readsPrec :: Int -> ReadS DescribeLoa
$creadsPrec :: Int -> ReadS DescribeLoa
Prelude.Read, Int -> DescribeLoa -> ShowS
[DescribeLoa] -> ShowS
DescribeLoa -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLoa] -> ShowS
$cshowList :: [DescribeLoa] -> ShowS
show :: DescribeLoa -> String
$cshow :: DescribeLoa -> String
showsPrec :: Int -> DescribeLoa -> ShowS
$cshowsPrec :: Int -> DescribeLoa -> ShowS
Prelude.Show, forall x. Rep DescribeLoa x -> DescribeLoa
forall x. DescribeLoa -> Rep DescribeLoa x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeLoa x -> DescribeLoa
$cfrom :: forall x. DescribeLoa -> Rep DescribeLoa x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLoa' 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:
--
-- 'loaContentType', 'describeLoa_loaContentType' - The standard media type for the LOA-CFA document. The only supported
-- value is application\/pdf.
--
-- 'providerName', 'describeLoa_providerName' - The name of the service provider who establishes connectivity on your
-- behalf. If you specify this parameter, the LOA-CFA lists the provider
-- name alongside your company name as the requester of the cross connect.
--
-- 'connectionId', 'describeLoa_connectionId' - The ID of a connection, LAG, or interconnect.
newDescribeLoa ::
  -- | 'connectionId'
  Prelude.Text ->
  DescribeLoa
newDescribeLoa :: Text -> DescribeLoa
newDescribeLoa Text
pConnectionId_ =
  DescribeLoa'
    { $sel:loaContentType:DescribeLoa' :: Maybe LoaContentType
loaContentType = forall a. Maybe a
Prelude.Nothing,
      $sel:providerName:DescribeLoa' :: Maybe Text
providerName = forall a. Maybe a
Prelude.Nothing,
      $sel:connectionId:DescribeLoa' :: Text
connectionId = Text
pConnectionId_
    }

-- | The standard media type for the LOA-CFA document. The only supported
-- value is application\/pdf.
describeLoa_loaContentType :: Lens.Lens' DescribeLoa (Prelude.Maybe LoaContentType)
describeLoa_loaContentType :: Lens' DescribeLoa (Maybe LoaContentType)
describeLoa_loaContentType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLoa' {Maybe LoaContentType
loaContentType :: Maybe LoaContentType
$sel:loaContentType:DescribeLoa' :: DescribeLoa -> Maybe LoaContentType
loaContentType} -> Maybe LoaContentType
loaContentType) (\s :: DescribeLoa
s@DescribeLoa' {} Maybe LoaContentType
a -> DescribeLoa
s {$sel:loaContentType:DescribeLoa' :: Maybe LoaContentType
loaContentType = Maybe LoaContentType
a} :: DescribeLoa)

-- | The name of the service provider who establishes connectivity on your
-- behalf. If you specify this parameter, the LOA-CFA lists the provider
-- name alongside your company name as the requester of the cross connect.
describeLoa_providerName :: Lens.Lens' DescribeLoa (Prelude.Maybe Prelude.Text)
describeLoa_providerName :: Lens' DescribeLoa (Maybe Text)
describeLoa_providerName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLoa' {Maybe Text
providerName :: Maybe Text
$sel:providerName:DescribeLoa' :: DescribeLoa -> Maybe Text
providerName} -> Maybe Text
providerName) (\s :: DescribeLoa
s@DescribeLoa' {} Maybe Text
a -> DescribeLoa
s {$sel:providerName:DescribeLoa' :: Maybe Text
providerName = Maybe Text
a} :: DescribeLoa)

-- | The ID of a connection, LAG, or interconnect.
describeLoa_connectionId :: Lens.Lens' DescribeLoa Prelude.Text
describeLoa_connectionId :: Lens' DescribeLoa Text
describeLoa_connectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLoa' {Text
connectionId :: Text
$sel:connectionId:DescribeLoa' :: DescribeLoa -> Text
connectionId} -> Text
connectionId) (\s :: DescribeLoa
s@DescribeLoa' {} Text
a -> DescribeLoa
s {$sel:connectionId:DescribeLoa' :: Text
connectionId = Text
a} :: DescribeLoa)

instance Core.AWSRequest DescribeLoa where
  type AWSResponse DescribeLoa = DescribeLoaResponse
  request :: (Service -> Service) -> DescribeLoa -> Request DescribeLoa
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 DescribeLoa
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeLoa)))
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 Base64 -> Maybe LoaContentType -> Int -> DescribeLoaResponse
DescribeLoaResponse'
            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
"loaContent")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"loaContentType")
            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 DescribeLoa where
  hashWithSalt :: Int -> DescribeLoa -> Int
hashWithSalt Int
_salt DescribeLoa' {Maybe Text
Maybe LoaContentType
Text
connectionId :: Text
providerName :: Maybe Text
loaContentType :: Maybe LoaContentType
$sel:connectionId:DescribeLoa' :: DescribeLoa -> Text
$sel:providerName:DescribeLoa' :: DescribeLoa -> Maybe Text
$sel:loaContentType:DescribeLoa' :: DescribeLoa -> Maybe LoaContentType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LoaContentType
loaContentType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
providerName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
connectionId

instance Prelude.NFData DescribeLoa where
  rnf :: DescribeLoa -> ()
rnf DescribeLoa' {Maybe Text
Maybe LoaContentType
Text
connectionId :: Text
providerName :: Maybe Text
loaContentType :: Maybe LoaContentType
$sel:connectionId:DescribeLoa' :: DescribeLoa -> Text
$sel:providerName:DescribeLoa' :: DescribeLoa -> Maybe Text
$sel:loaContentType:DescribeLoa' :: DescribeLoa -> Maybe LoaContentType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe LoaContentType
loaContentType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
providerName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
connectionId

instance Data.ToHeaders DescribeLoa where
  toHeaders :: DescribeLoa -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"OvertureService.DescribeLoa" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DescribeLoa where
  toJSON :: DescribeLoa -> Value
toJSON DescribeLoa' {Maybe Text
Maybe LoaContentType
Text
connectionId :: Text
providerName :: Maybe Text
loaContentType :: Maybe LoaContentType
$sel:connectionId:DescribeLoa' :: DescribeLoa -> Text
$sel:providerName:DescribeLoa' :: DescribeLoa -> Maybe Text
$sel:loaContentType:DescribeLoa' :: DescribeLoa -> Maybe LoaContentType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"loaContentType" 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 LoaContentType
loaContentType,
            (Key
"providerName" 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 Text
providerName,
            forall a. a -> Maybe a
Prelude.Just (Key
"connectionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
connectionId)
          ]
      )

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

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

-- | Information about a Letter of Authorization - Connecting Facility
-- Assignment (LOA-CFA) for a connection.
--
-- /See:/ 'newDescribeLoaResponse' smart constructor.
data DescribeLoaResponse = DescribeLoaResponse'
  { -- | The binary contents of the LOA-CFA document.
    DescribeLoaResponse -> Maybe Base64
loaContent :: Prelude.Maybe Data.Base64,
    -- | The standard media type for the LOA-CFA document. The only supported
    -- value is application\/pdf.
    DescribeLoaResponse -> Maybe LoaContentType
loaContentType :: Prelude.Maybe LoaContentType,
    -- | The response's http status code.
    DescribeLoaResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeLoaResponse -> DescribeLoaResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLoaResponse -> DescribeLoaResponse -> Bool
$c/= :: DescribeLoaResponse -> DescribeLoaResponse -> Bool
== :: DescribeLoaResponse -> DescribeLoaResponse -> Bool
$c== :: DescribeLoaResponse -> DescribeLoaResponse -> Bool
Prelude.Eq, ReadPrec [DescribeLoaResponse]
ReadPrec DescribeLoaResponse
Int -> ReadS DescribeLoaResponse
ReadS [DescribeLoaResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLoaResponse]
$creadListPrec :: ReadPrec [DescribeLoaResponse]
readPrec :: ReadPrec DescribeLoaResponse
$creadPrec :: ReadPrec DescribeLoaResponse
readList :: ReadS [DescribeLoaResponse]
$creadList :: ReadS [DescribeLoaResponse]
readsPrec :: Int -> ReadS DescribeLoaResponse
$creadsPrec :: Int -> ReadS DescribeLoaResponse
Prelude.Read, Int -> DescribeLoaResponse -> ShowS
[DescribeLoaResponse] -> ShowS
DescribeLoaResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLoaResponse] -> ShowS
$cshowList :: [DescribeLoaResponse] -> ShowS
show :: DescribeLoaResponse -> String
$cshow :: DescribeLoaResponse -> String
showsPrec :: Int -> DescribeLoaResponse -> ShowS
$cshowsPrec :: Int -> DescribeLoaResponse -> ShowS
Prelude.Show, forall x. Rep DescribeLoaResponse x -> DescribeLoaResponse
forall x. DescribeLoaResponse -> Rep DescribeLoaResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeLoaResponse x -> DescribeLoaResponse
$cfrom :: forall x. DescribeLoaResponse -> Rep DescribeLoaResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLoaResponse' 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:
--
-- 'loaContent', 'describeLoaResponse_loaContent' - The binary contents of the LOA-CFA document.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'loaContentType', 'describeLoaResponse_loaContentType' - The standard media type for the LOA-CFA document. The only supported
-- value is application\/pdf.
--
-- 'httpStatus', 'describeLoaResponse_httpStatus' - The response's http status code.
newDescribeLoaResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeLoaResponse
newDescribeLoaResponse :: Int -> DescribeLoaResponse
newDescribeLoaResponse Int
pHttpStatus_ =
  DescribeLoaResponse'
    { $sel:loaContent:DescribeLoaResponse' :: Maybe Base64
loaContent = forall a. Maybe a
Prelude.Nothing,
      $sel:loaContentType:DescribeLoaResponse' :: Maybe LoaContentType
loaContentType = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeLoaResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The binary contents of the LOA-CFA document.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
describeLoaResponse_loaContent :: Lens.Lens' DescribeLoaResponse (Prelude.Maybe Prelude.ByteString)
describeLoaResponse_loaContent :: Lens' DescribeLoaResponse (Maybe ByteString)
describeLoaResponse_loaContent = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLoaResponse' {Maybe Base64
loaContent :: Maybe Base64
$sel:loaContent:DescribeLoaResponse' :: DescribeLoaResponse -> Maybe Base64
loaContent} -> Maybe Base64
loaContent) (\s :: DescribeLoaResponse
s@DescribeLoaResponse' {} Maybe Base64
a -> DescribeLoaResponse
s {$sel:loaContent:DescribeLoaResponse' :: Maybe Base64
loaContent = Maybe Base64
a} :: DescribeLoaResponse) 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 Iso' Base64 ByteString
Data._Base64

-- | The standard media type for the LOA-CFA document. The only supported
-- value is application\/pdf.
describeLoaResponse_loaContentType :: Lens.Lens' DescribeLoaResponse (Prelude.Maybe LoaContentType)
describeLoaResponse_loaContentType :: Lens' DescribeLoaResponse (Maybe LoaContentType)
describeLoaResponse_loaContentType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLoaResponse' {Maybe LoaContentType
loaContentType :: Maybe LoaContentType
$sel:loaContentType:DescribeLoaResponse' :: DescribeLoaResponse -> Maybe LoaContentType
loaContentType} -> Maybe LoaContentType
loaContentType) (\s :: DescribeLoaResponse
s@DescribeLoaResponse' {} Maybe LoaContentType
a -> DescribeLoaResponse
s {$sel:loaContentType:DescribeLoaResponse' :: Maybe LoaContentType
loaContentType = Maybe LoaContentType
a} :: DescribeLoaResponse)

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

instance Prelude.NFData DescribeLoaResponse where
  rnf :: DescribeLoaResponse -> ()
rnf DescribeLoaResponse' {Int
Maybe Base64
Maybe LoaContentType
httpStatus :: Int
loaContentType :: Maybe LoaContentType
loaContent :: Maybe Base64
$sel:httpStatus:DescribeLoaResponse' :: DescribeLoaResponse -> Int
$sel:loaContentType:DescribeLoaResponse' :: DescribeLoaResponse -> Maybe LoaContentType
$sel:loaContent:DescribeLoaResponse' :: DescribeLoaResponse -> Maybe Base64
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Base64
loaContent
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe LoaContentType
loaContentType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus