{-# 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.AutoScaling.DescribeTerminationPolicyTypes
-- 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)
--
-- Describes the termination policies supported by Amazon EC2 Auto Scaling.
--
-- For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-instance-termination.html Controlling which Auto Scaling instances terminate during scale in>
-- in the /Amazon EC2 Auto Scaling User Guide/.
module Amazonka.AutoScaling.DescribeTerminationPolicyTypes
  ( -- * Creating a Request
    DescribeTerminationPolicyTypes (..),
    newDescribeTerminationPolicyTypes,

    -- * Destructuring the Response
    DescribeTerminationPolicyTypesResponse (..),
    newDescribeTerminationPolicyTypesResponse,

    -- * Response Lenses
    describeTerminationPolicyTypesResponse_terminationPolicyTypes,
    describeTerminationPolicyTypesResponse_httpStatus,
  )
where

import Amazonka.AutoScaling.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

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

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

instance
  Core.AWSRequest
    DescribeTerminationPolicyTypes
  where
  type
    AWSResponse DescribeTerminationPolicyTypes =
      DescribeTerminationPolicyTypesResponse
  request :: DescribeTerminationPolicyTypes
-> Request DescribeTerminationPolicyTypes
request = Service
-> DescribeTerminationPolicyTypes
-> Request DescribeTerminationPolicyTypes
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeTerminationPolicyTypes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeTerminationPolicyTypes)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeTerminationPolicyTypes))
-> Logger
-> Service
-> Proxy DescribeTerminationPolicyTypes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeTerminationPolicyTypes)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DescribeTerminationPolicyTypesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [Text] -> Int -> DescribeTerminationPolicyTypesResponse
DescribeTerminationPolicyTypesResponse'
            (Maybe [Text] -> Int -> DescribeTerminationPolicyTypesResponse)
-> Either String (Maybe [Text])
-> Either String (Int -> DescribeTerminationPolicyTypesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"TerminationPolicyTypes"
                            Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Int -> DescribeTerminationPolicyTypesResponse)
-> Either String Int
-> Either String DescribeTerminationPolicyTypesResponse
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
    DescribeTerminationPolicyTypes

instance
  Prelude.NFData
    DescribeTerminationPolicyTypes

instance
  Core.ToHeaders
    DescribeTerminationPolicyTypes
  where
  toHeaders :: DescribeTerminationPolicyTypes -> ResponseHeaders
toHeaders = ResponseHeaders
-> DescribeTerminationPolicyTypes -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery DescribeTerminationPolicyTypes where
  toQuery :: DescribeTerminationPolicyTypes -> QueryString
toQuery =
    QueryString -> DescribeTerminationPolicyTypes -> QueryString
forall a b. a -> b -> a
Prelude.const
      ( [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ ByteString
"Action"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ( ByteString
"DescribeTerminationPolicyTypes" ::
                          Prelude.ByteString
                      ),
            ByteString
"Version"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString)
          ]
      )

-- | /See:/ 'newDescribeTerminationPolicyTypesResponse' smart constructor.
data DescribeTerminationPolicyTypesResponse = DescribeTerminationPolicyTypesResponse'
  { -- | The termination policies supported by Amazon EC2 Auto Scaling:
    -- @OldestInstance@, @OldestLaunchConfiguration@, @NewestInstance@,
    -- @ClosestToNextInstanceHour@, @Default@, @OldestLaunchTemplate@, and
    -- @AllocationStrategy@.
    DescribeTerminationPolicyTypesResponse -> Maybe [Text]
terminationPolicyTypes :: Prelude.Maybe [Prelude.Text],
    -- | The response's http status code.
    DescribeTerminationPolicyTypesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeTerminationPolicyTypesResponse
-> DescribeTerminationPolicyTypesResponse -> Bool
(DescribeTerminationPolicyTypesResponse
 -> DescribeTerminationPolicyTypesResponse -> Bool)
-> (DescribeTerminationPolicyTypesResponse
    -> DescribeTerminationPolicyTypesResponse -> Bool)
-> Eq DescribeTerminationPolicyTypesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeTerminationPolicyTypesResponse
-> DescribeTerminationPolicyTypesResponse -> Bool
$c/= :: DescribeTerminationPolicyTypesResponse
-> DescribeTerminationPolicyTypesResponse -> Bool
== :: DescribeTerminationPolicyTypesResponse
-> DescribeTerminationPolicyTypesResponse -> Bool
$c== :: DescribeTerminationPolicyTypesResponse
-> DescribeTerminationPolicyTypesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeTerminationPolicyTypesResponse]
ReadPrec DescribeTerminationPolicyTypesResponse
Int -> ReadS DescribeTerminationPolicyTypesResponse
ReadS [DescribeTerminationPolicyTypesResponse]
(Int -> ReadS DescribeTerminationPolicyTypesResponse)
-> ReadS [DescribeTerminationPolicyTypesResponse]
-> ReadPrec DescribeTerminationPolicyTypesResponse
-> ReadPrec [DescribeTerminationPolicyTypesResponse]
-> Read DescribeTerminationPolicyTypesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeTerminationPolicyTypesResponse]
$creadListPrec :: ReadPrec [DescribeTerminationPolicyTypesResponse]
readPrec :: ReadPrec DescribeTerminationPolicyTypesResponse
$creadPrec :: ReadPrec DescribeTerminationPolicyTypesResponse
readList :: ReadS [DescribeTerminationPolicyTypesResponse]
$creadList :: ReadS [DescribeTerminationPolicyTypesResponse]
readsPrec :: Int -> ReadS DescribeTerminationPolicyTypesResponse
$creadsPrec :: Int -> ReadS DescribeTerminationPolicyTypesResponse
Prelude.Read, Int -> DescribeTerminationPolicyTypesResponse -> ShowS
[DescribeTerminationPolicyTypesResponse] -> ShowS
DescribeTerminationPolicyTypesResponse -> String
(Int -> DescribeTerminationPolicyTypesResponse -> ShowS)
-> (DescribeTerminationPolicyTypesResponse -> String)
-> ([DescribeTerminationPolicyTypesResponse] -> ShowS)
-> Show DescribeTerminationPolicyTypesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeTerminationPolicyTypesResponse] -> ShowS
$cshowList :: [DescribeTerminationPolicyTypesResponse] -> ShowS
show :: DescribeTerminationPolicyTypesResponse -> String
$cshow :: DescribeTerminationPolicyTypesResponse -> String
showsPrec :: Int -> DescribeTerminationPolicyTypesResponse -> ShowS
$cshowsPrec :: Int -> DescribeTerminationPolicyTypesResponse -> ShowS
Prelude.Show, (forall x.
 DescribeTerminationPolicyTypesResponse
 -> Rep DescribeTerminationPolicyTypesResponse x)
-> (forall x.
    Rep DescribeTerminationPolicyTypesResponse x
    -> DescribeTerminationPolicyTypesResponse)
-> Generic DescribeTerminationPolicyTypesResponse
forall x.
Rep DescribeTerminationPolicyTypesResponse x
-> DescribeTerminationPolicyTypesResponse
forall x.
DescribeTerminationPolicyTypesResponse
-> Rep DescribeTerminationPolicyTypesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeTerminationPolicyTypesResponse x
-> DescribeTerminationPolicyTypesResponse
$cfrom :: forall x.
DescribeTerminationPolicyTypesResponse
-> Rep DescribeTerminationPolicyTypesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeTerminationPolicyTypesResponse' 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:
--
-- 'terminationPolicyTypes', 'describeTerminationPolicyTypesResponse_terminationPolicyTypes' - The termination policies supported by Amazon EC2 Auto Scaling:
-- @OldestInstance@, @OldestLaunchConfiguration@, @NewestInstance@,
-- @ClosestToNextInstanceHour@, @Default@, @OldestLaunchTemplate@, and
-- @AllocationStrategy@.
--
-- 'httpStatus', 'describeTerminationPolicyTypesResponse_httpStatus' - The response's http status code.
newDescribeTerminationPolicyTypesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeTerminationPolicyTypesResponse
newDescribeTerminationPolicyTypesResponse :: Int -> DescribeTerminationPolicyTypesResponse
newDescribeTerminationPolicyTypesResponse
  Int
pHttpStatus_ =
    DescribeTerminationPolicyTypesResponse' :: Maybe [Text] -> Int -> DescribeTerminationPolicyTypesResponse
DescribeTerminationPolicyTypesResponse'
      { $sel:terminationPolicyTypes:DescribeTerminationPolicyTypesResponse' :: Maybe [Text]
terminationPolicyTypes =
          Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeTerminationPolicyTypesResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The termination policies supported by Amazon EC2 Auto Scaling:
-- @OldestInstance@, @OldestLaunchConfiguration@, @NewestInstance@,
-- @ClosestToNextInstanceHour@, @Default@, @OldestLaunchTemplate@, and
-- @AllocationStrategy@.
describeTerminationPolicyTypesResponse_terminationPolicyTypes :: Lens.Lens' DescribeTerminationPolicyTypesResponse (Prelude.Maybe [Prelude.Text])
describeTerminationPolicyTypesResponse_terminationPolicyTypes :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeTerminationPolicyTypesResponse
-> f DescribeTerminationPolicyTypesResponse
describeTerminationPolicyTypesResponse_terminationPolicyTypes = (DescribeTerminationPolicyTypesResponse -> Maybe [Text])
-> (DescribeTerminationPolicyTypesResponse
    -> Maybe [Text] -> DescribeTerminationPolicyTypesResponse)
-> Lens
     DescribeTerminationPolicyTypesResponse
     DescribeTerminationPolicyTypesResponse
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTerminationPolicyTypesResponse' {Maybe [Text]
terminationPolicyTypes :: Maybe [Text]
$sel:terminationPolicyTypes:DescribeTerminationPolicyTypesResponse' :: DescribeTerminationPolicyTypesResponse -> Maybe [Text]
terminationPolicyTypes} -> Maybe [Text]
terminationPolicyTypes) (\s :: DescribeTerminationPolicyTypesResponse
s@DescribeTerminationPolicyTypesResponse' {} Maybe [Text]
a -> DescribeTerminationPolicyTypesResponse
s {$sel:terminationPolicyTypes:DescribeTerminationPolicyTypesResponse' :: Maybe [Text]
terminationPolicyTypes = Maybe [Text]
a} :: DescribeTerminationPolicyTypesResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeTerminationPolicyTypesResponse
 -> f DescribeTerminationPolicyTypesResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeTerminationPolicyTypesResponse
-> f DescribeTerminationPolicyTypesResponse
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.
describeTerminationPolicyTypesResponse_httpStatus :: Lens.Lens' DescribeTerminationPolicyTypesResponse Prelude.Int
describeTerminationPolicyTypesResponse_httpStatus :: (Int -> f Int)
-> DescribeTerminationPolicyTypesResponse
-> f DescribeTerminationPolicyTypesResponse
describeTerminationPolicyTypesResponse_httpStatus = (DescribeTerminationPolicyTypesResponse -> Int)
-> (DescribeTerminationPolicyTypesResponse
    -> Int -> DescribeTerminationPolicyTypesResponse)
-> Lens
     DescribeTerminationPolicyTypesResponse
     DescribeTerminationPolicyTypesResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTerminationPolicyTypesResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeTerminationPolicyTypesResponse' :: DescribeTerminationPolicyTypesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeTerminationPolicyTypesResponse
s@DescribeTerminationPolicyTypesResponse' {} Int
a -> DescribeTerminationPolicyTypesResponse
s {$sel:httpStatus:DescribeTerminationPolicyTypesResponse' :: Int
httpStatus = Int
a} :: DescribeTerminationPolicyTypesResponse)

instance
  Prelude.NFData
    DescribeTerminationPolicyTypesResponse