{-# 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.CloudHSM.ListAvailableZones
-- 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)
--
-- This is documentation for __AWS CloudHSM Classic__. For more
-- information, see
-- <http://aws.amazon.com/cloudhsm/faqs-classic/ AWS CloudHSM Classic FAQs>,
-- the
-- <https://docs.aws.amazon.com/cloudhsm/classic/userguide/ AWS CloudHSM Classic User Guide>,
-- and the
-- <https://docs.aws.amazon.com/cloudhsm/classic/APIReference/ AWS CloudHSM Classic API Reference>.
--
-- __For information about the current version of AWS CloudHSM__, see
-- <http://aws.amazon.com/cloudhsm/ AWS CloudHSM>, the
-- <https://docs.aws.amazon.com/cloudhsm/latest/userguide/ AWS CloudHSM User Guide>,
-- and the
-- <https://docs.aws.amazon.com/cloudhsm/latest/APIReference/ AWS CloudHSM API Reference>.
--
-- Lists the Availability Zones that have available AWS CloudHSM capacity.
module Amazonka.CloudHSM.ListAvailableZones
  ( -- * Creating a Request
    ListAvailableZones (..),
    newListAvailableZones,

    -- * Destructuring the Response
    ListAvailableZonesResponse (..),
    newListAvailableZonesResponse,

    -- * Response Lenses
    listAvailableZonesResponse_aZList,
    listAvailableZonesResponse_httpStatus,
  )
where

import Amazonka.CloudHSM.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Contains the inputs for the ListAvailableZones action.
--
-- /See:/ 'newListAvailableZones' smart constructor.
data ListAvailableZones = ListAvailableZones'
  {
  }
  deriving (ListAvailableZones -> ListAvailableZones -> Bool
(ListAvailableZones -> ListAvailableZones -> Bool)
-> (ListAvailableZones -> ListAvailableZones -> Bool)
-> Eq ListAvailableZones
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAvailableZones -> ListAvailableZones -> Bool
$c/= :: ListAvailableZones -> ListAvailableZones -> Bool
== :: ListAvailableZones -> ListAvailableZones -> Bool
$c== :: ListAvailableZones -> ListAvailableZones -> Bool
Prelude.Eq, ReadPrec [ListAvailableZones]
ReadPrec ListAvailableZones
Int -> ReadS ListAvailableZones
ReadS [ListAvailableZones]
(Int -> ReadS ListAvailableZones)
-> ReadS [ListAvailableZones]
-> ReadPrec ListAvailableZones
-> ReadPrec [ListAvailableZones]
-> Read ListAvailableZones
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAvailableZones]
$creadListPrec :: ReadPrec [ListAvailableZones]
readPrec :: ReadPrec ListAvailableZones
$creadPrec :: ReadPrec ListAvailableZones
readList :: ReadS [ListAvailableZones]
$creadList :: ReadS [ListAvailableZones]
readsPrec :: Int -> ReadS ListAvailableZones
$creadsPrec :: Int -> ReadS ListAvailableZones
Prelude.Read, Int -> ListAvailableZones -> ShowS
[ListAvailableZones] -> ShowS
ListAvailableZones -> String
(Int -> ListAvailableZones -> ShowS)
-> (ListAvailableZones -> String)
-> ([ListAvailableZones] -> ShowS)
-> Show ListAvailableZones
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAvailableZones] -> ShowS
$cshowList :: [ListAvailableZones] -> ShowS
show :: ListAvailableZones -> String
$cshow :: ListAvailableZones -> String
showsPrec :: Int -> ListAvailableZones -> ShowS
$cshowsPrec :: Int -> ListAvailableZones -> ShowS
Prelude.Show, (forall x. ListAvailableZones -> Rep ListAvailableZones x)
-> (forall x. Rep ListAvailableZones x -> ListAvailableZones)
-> Generic ListAvailableZones
forall x. Rep ListAvailableZones x -> ListAvailableZones
forall x. ListAvailableZones -> Rep ListAvailableZones x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAvailableZones x -> ListAvailableZones
$cfrom :: forall x. ListAvailableZones -> Rep ListAvailableZones x
Prelude.Generic)

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

instance Core.AWSRequest ListAvailableZones where
  type
    AWSResponse ListAvailableZones =
      ListAvailableZonesResponse
  request :: ListAvailableZones -> Request ListAvailableZones
request = Service -> ListAvailableZones -> Request ListAvailableZones
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListAvailableZones
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAvailableZones)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListAvailableZones))
-> Logger
-> Service
-> Proxy ListAvailableZones
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAvailableZones)))
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 [Text] -> Int -> ListAvailableZonesResponse
ListAvailableZonesResponse'
            (Maybe [Text] -> Int -> ListAvailableZonesResponse)
-> Either String (Maybe [Text])
-> Either String (Int -> ListAvailableZonesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AZList" Either String (Maybe (Maybe [Text]))
-> Maybe [Text] -> Either String (Maybe [Text])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListAvailableZonesResponse)
-> Either String Int -> Either String ListAvailableZonesResponse
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 ListAvailableZones

instance Prelude.NFData ListAvailableZones

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

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

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

-- | /See:/ 'newListAvailableZonesResponse' smart constructor.
data ListAvailableZonesResponse = ListAvailableZonesResponse'
  { -- | The list of Availability Zones that have available AWS CloudHSM
    -- capacity.
    ListAvailableZonesResponse -> Maybe [Text]
aZList :: Prelude.Maybe [Prelude.Text],
    -- | The response's http status code.
    ListAvailableZonesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAvailableZonesResponse -> ListAvailableZonesResponse -> Bool
(ListAvailableZonesResponse -> ListAvailableZonesResponse -> Bool)
-> (ListAvailableZonesResponse
    -> ListAvailableZonesResponse -> Bool)
-> Eq ListAvailableZonesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAvailableZonesResponse -> ListAvailableZonesResponse -> Bool
$c/= :: ListAvailableZonesResponse -> ListAvailableZonesResponse -> Bool
== :: ListAvailableZonesResponse -> ListAvailableZonesResponse -> Bool
$c== :: ListAvailableZonesResponse -> ListAvailableZonesResponse -> Bool
Prelude.Eq, ReadPrec [ListAvailableZonesResponse]
ReadPrec ListAvailableZonesResponse
Int -> ReadS ListAvailableZonesResponse
ReadS [ListAvailableZonesResponse]
(Int -> ReadS ListAvailableZonesResponse)
-> ReadS [ListAvailableZonesResponse]
-> ReadPrec ListAvailableZonesResponse
-> ReadPrec [ListAvailableZonesResponse]
-> Read ListAvailableZonesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAvailableZonesResponse]
$creadListPrec :: ReadPrec [ListAvailableZonesResponse]
readPrec :: ReadPrec ListAvailableZonesResponse
$creadPrec :: ReadPrec ListAvailableZonesResponse
readList :: ReadS [ListAvailableZonesResponse]
$creadList :: ReadS [ListAvailableZonesResponse]
readsPrec :: Int -> ReadS ListAvailableZonesResponse
$creadsPrec :: Int -> ReadS ListAvailableZonesResponse
Prelude.Read, Int -> ListAvailableZonesResponse -> ShowS
[ListAvailableZonesResponse] -> ShowS
ListAvailableZonesResponse -> String
(Int -> ListAvailableZonesResponse -> ShowS)
-> (ListAvailableZonesResponse -> String)
-> ([ListAvailableZonesResponse] -> ShowS)
-> Show ListAvailableZonesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAvailableZonesResponse] -> ShowS
$cshowList :: [ListAvailableZonesResponse] -> ShowS
show :: ListAvailableZonesResponse -> String
$cshow :: ListAvailableZonesResponse -> String
showsPrec :: Int -> ListAvailableZonesResponse -> ShowS
$cshowsPrec :: Int -> ListAvailableZonesResponse -> ShowS
Prelude.Show, (forall x.
 ListAvailableZonesResponse -> Rep ListAvailableZonesResponse x)
-> (forall x.
    Rep ListAvailableZonesResponse x -> ListAvailableZonesResponse)
-> Generic ListAvailableZonesResponse
forall x.
Rep ListAvailableZonesResponse x -> ListAvailableZonesResponse
forall x.
ListAvailableZonesResponse -> Rep ListAvailableZonesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAvailableZonesResponse x -> ListAvailableZonesResponse
$cfrom :: forall x.
ListAvailableZonesResponse -> Rep ListAvailableZonesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAvailableZonesResponse' 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:
--
-- 'aZList', 'listAvailableZonesResponse_aZList' - The list of Availability Zones that have available AWS CloudHSM
-- capacity.
--
-- 'httpStatus', 'listAvailableZonesResponse_httpStatus' - The response's http status code.
newListAvailableZonesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAvailableZonesResponse
newListAvailableZonesResponse :: Int -> ListAvailableZonesResponse
newListAvailableZonesResponse Int
pHttpStatus_ =
  ListAvailableZonesResponse' :: Maybe [Text] -> Int -> ListAvailableZonesResponse
ListAvailableZonesResponse'
    { $sel:aZList:ListAvailableZonesResponse' :: Maybe [Text]
aZList =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAvailableZonesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of Availability Zones that have available AWS CloudHSM
-- capacity.
listAvailableZonesResponse_aZList :: Lens.Lens' ListAvailableZonesResponse (Prelude.Maybe [Prelude.Text])
listAvailableZonesResponse_aZList :: (Maybe [Text] -> f (Maybe [Text]))
-> ListAvailableZonesResponse -> f ListAvailableZonesResponse
listAvailableZonesResponse_aZList = (ListAvailableZonesResponse -> Maybe [Text])
-> (ListAvailableZonesResponse
    -> Maybe [Text] -> ListAvailableZonesResponse)
-> Lens
     ListAvailableZonesResponse
     ListAvailableZonesResponse
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAvailableZonesResponse' {Maybe [Text]
aZList :: Maybe [Text]
$sel:aZList:ListAvailableZonesResponse' :: ListAvailableZonesResponse -> Maybe [Text]
aZList} -> Maybe [Text]
aZList) (\s :: ListAvailableZonesResponse
s@ListAvailableZonesResponse' {} Maybe [Text]
a -> ListAvailableZonesResponse
s {$sel:aZList:ListAvailableZonesResponse' :: Maybe [Text]
aZList = Maybe [Text]
a} :: ListAvailableZonesResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListAvailableZonesResponse -> f ListAvailableZonesResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListAvailableZonesResponse
-> f ListAvailableZonesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListAvailableZonesResponse