{-# 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.DescribeLocations
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the Direct Connect locations in the current Amazon Web Services
-- Region. These are the locations that can be selected when calling
-- CreateConnection or CreateInterconnect.
module Amazonka.DirectConnect.DescribeLocations
  ( -- * Creating a Request
    DescribeLocations (..),
    newDescribeLocations,

    -- * Destructuring the Response
    DescribeLocationsResponse (..),
    newDescribeLocationsResponse,

    -- * Response Lenses
    describeLocationsResponse_locations,
    describeLocationsResponse_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:/ 'newDescribeLocations' smart constructor.
data DescribeLocations = DescribeLocations'
  {
  }
  deriving (DescribeLocations -> DescribeLocations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLocations -> DescribeLocations -> Bool
$c/= :: DescribeLocations -> DescribeLocations -> Bool
== :: DescribeLocations -> DescribeLocations -> Bool
$c== :: DescribeLocations -> DescribeLocations -> Bool
Prelude.Eq, ReadPrec [DescribeLocations]
ReadPrec DescribeLocations
Int -> ReadS DescribeLocations
ReadS [DescribeLocations]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLocations]
$creadListPrec :: ReadPrec [DescribeLocations]
readPrec :: ReadPrec DescribeLocations
$creadPrec :: ReadPrec DescribeLocations
readList :: ReadS [DescribeLocations]
$creadList :: ReadS [DescribeLocations]
readsPrec :: Int -> ReadS DescribeLocations
$creadsPrec :: Int -> ReadS DescribeLocations
Prelude.Read, Int -> DescribeLocations -> ShowS
[DescribeLocations] -> ShowS
DescribeLocations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLocations] -> ShowS
$cshowList :: [DescribeLocations] -> ShowS
show :: DescribeLocations -> String
$cshow :: DescribeLocations -> String
showsPrec :: Int -> DescribeLocations -> ShowS
$cshowsPrec :: Int -> DescribeLocations -> ShowS
Prelude.Show, forall x. Rep DescribeLocations x -> DescribeLocations
forall x. DescribeLocations -> Rep DescribeLocations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeLocations x -> DescribeLocations
$cfrom :: forall x. DescribeLocations -> Rep DescribeLocations x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLocations' 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.
newDescribeLocations ::
  DescribeLocations
newDescribeLocations :: DescribeLocations
newDescribeLocations = DescribeLocations
DescribeLocations'

instance Core.AWSRequest DescribeLocations where
  type
    AWSResponse DescribeLocations =
      DescribeLocationsResponse
  request :: (Service -> Service)
-> DescribeLocations -> Request DescribeLocations
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 DescribeLocations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeLocations)))
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 [Location] -> Int -> DescribeLocationsResponse
DescribeLocationsResponse'
            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
"locations" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 DescribeLocations where
  hashWithSalt :: Int -> DescribeLocations -> Int
hashWithSalt Int
_salt DescribeLocations
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData DescribeLocations where
  rnf :: DescribeLocations -> ()
rnf DescribeLocations
_ = ()

instance Data.ToHeaders DescribeLocations where
  toHeaders :: DescribeLocations -> 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.DescribeLocations" ::
                          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 DescribeLocations where
  toJSON :: DescribeLocations -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

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

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

-- | /See:/ 'newDescribeLocationsResponse' smart constructor.
data DescribeLocationsResponse = DescribeLocationsResponse'
  { -- | The locations.
    DescribeLocationsResponse -> Maybe [Location]
locations :: Prelude.Maybe [Location],
    -- | The response's http status code.
    DescribeLocationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeLocationsResponse -> DescribeLocationsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLocationsResponse -> DescribeLocationsResponse -> Bool
$c/= :: DescribeLocationsResponse -> DescribeLocationsResponse -> Bool
== :: DescribeLocationsResponse -> DescribeLocationsResponse -> Bool
$c== :: DescribeLocationsResponse -> DescribeLocationsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeLocationsResponse]
ReadPrec DescribeLocationsResponse
Int -> ReadS DescribeLocationsResponse
ReadS [DescribeLocationsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLocationsResponse]
$creadListPrec :: ReadPrec [DescribeLocationsResponse]
readPrec :: ReadPrec DescribeLocationsResponse
$creadPrec :: ReadPrec DescribeLocationsResponse
readList :: ReadS [DescribeLocationsResponse]
$creadList :: ReadS [DescribeLocationsResponse]
readsPrec :: Int -> ReadS DescribeLocationsResponse
$creadsPrec :: Int -> ReadS DescribeLocationsResponse
Prelude.Read, Int -> DescribeLocationsResponse -> ShowS
[DescribeLocationsResponse] -> ShowS
DescribeLocationsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLocationsResponse] -> ShowS
$cshowList :: [DescribeLocationsResponse] -> ShowS
show :: DescribeLocationsResponse -> String
$cshow :: DescribeLocationsResponse -> String
showsPrec :: Int -> DescribeLocationsResponse -> ShowS
$cshowsPrec :: Int -> DescribeLocationsResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeLocationsResponse x -> DescribeLocationsResponse
forall x.
DescribeLocationsResponse -> Rep DescribeLocationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeLocationsResponse x -> DescribeLocationsResponse
$cfrom :: forall x.
DescribeLocationsResponse -> Rep DescribeLocationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLocationsResponse' 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:
--
-- 'locations', 'describeLocationsResponse_locations' - The locations.
--
-- 'httpStatus', 'describeLocationsResponse_httpStatus' - The response's http status code.
newDescribeLocationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeLocationsResponse
newDescribeLocationsResponse :: Int -> DescribeLocationsResponse
newDescribeLocationsResponse Int
pHttpStatus_ =
  DescribeLocationsResponse'
    { $sel:locations:DescribeLocationsResponse' :: Maybe [Location]
locations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeLocationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The locations.
describeLocationsResponse_locations :: Lens.Lens' DescribeLocationsResponse (Prelude.Maybe [Location])
describeLocationsResponse_locations :: Lens' DescribeLocationsResponse (Maybe [Location])
describeLocationsResponse_locations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLocationsResponse' {Maybe [Location]
locations :: Maybe [Location]
$sel:locations:DescribeLocationsResponse' :: DescribeLocationsResponse -> Maybe [Location]
locations} -> Maybe [Location]
locations) (\s :: DescribeLocationsResponse
s@DescribeLocationsResponse' {} Maybe [Location]
a -> DescribeLocationsResponse
s {$sel:locations:DescribeLocationsResponse' :: Maybe [Location]
locations = Maybe [Location]
a} :: DescribeLocationsResponse) 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

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

instance Prelude.NFData DescribeLocationsResponse where
  rnf :: DescribeLocationsResponse -> ()
rnf DescribeLocationsResponse' {Int
Maybe [Location]
httpStatus :: Int
locations :: Maybe [Location]
$sel:httpStatus:DescribeLocationsResponse' :: DescribeLocationsResponse -> Int
$sel:locations:DescribeLocationsResponse' :: DescribeLocationsResponse -> Maybe [Location]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Location]
locations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus