{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.EC2.Types.InstanceSpecification
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EC2.Types.InstanceSpecification where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import qualified Amazonka.Prelude as Prelude

-- | The instance details to specify which volumes should be snapshotted.
--
-- /See:/ 'newInstanceSpecification' smart constructor.
data InstanceSpecification = InstanceSpecification'
  { -- | Excludes the root volume from being snapshotted.
    InstanceSpecification -> Maybe Bool
excludeBootVolume :: Prelude.Maybe Prelude.Bool,
    -- | The IDs of the data (non-root) volumes to exclude from the multi-volume
    -- snapshot set. If you specify the ID of the root volume, the request
    -- fails. To exclude the root volume, use __ExcludeBootVolume__.
    --
    -- You can specify up to 40 volume IDs per request.
    InstanceSpecification -> Maybe [Text]
excludeDataVolumeIds :: Prelude.Maybe [Prelude.Text],
    -- | The instance to specify which volumes should be snapshotted.
    InstanceSpecification -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text
  }
  deriving (InstanceSpecification -> InstanceSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceSpecification -> InstanceSpecification -> Bool
$c/= :: InstanceSpecification -> InstanceSpecification -> Bool
== :: InstanceSpecification -> InstanceSpecification -> Bool
$c== :: InstanceSpecification -> InstanceSpecification -> Bool
Prelude.Eq, ReadPrec [InstanceSpecification]
ReadPrec InstanceSpecification
Int -> ReadS InstanceSpecification
ReadS [InstanceSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceSpecification]
$creadListPrec :: ReadPrec [InstanceSpecification]
readPrec :: ReadPrec InstanceSpecification
$creadPrec :: ReadPrec InstanceSpecification
readList :: ReadS [InstanceSpecification]
$creadList :: ReadS [InstanceSpecification]
readsPrec :: Int -> ReadS InstanceSpecification
$creadsPrec :: Int -> ReadS InstanceSpecification
Prelude.Read, Int -> InstanceSpecification -> ShowS
[InstanceSpecification] -> ShowS
InstanceSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceSpecification] -> ShowS
$cshowList :: [InstanceSpecification] -> ShowS
show :: InstanceSpecification -> String
$cshow :: InstanceSpecification -> String
showsPrec :: Int -> InstanceSpecification -> ShowS
$cshowsPrec :: Int -> InstanceSpecification -> ShowS
Prelude.Show, forall x. Rep InstanceSpecification x -> InstanceSpecification
forall x. InstanceSpecification -> Rep InstanceSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceSpecification x -> InstanceSpecification
$cfrom :: forall x. InstanceSpecification -> Rep InstanceSpecification x
Prelude.Generic)

-- |
-- Create a value of 'InstanceSpecification' 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:
--
-- 'excludeBootVolume', 'instanceSpecification_excludeBootVolume' - Excludes the root volume from being snapshotted.
--
-- 'excludeDataVolumeIds', 'instanceSpecification_excludeDataVolumeIds' - The IDs of the data (non-root) volumes to exclude from the multi-volume
-- snapshot set. If you specify the ID of the root volume, the request
-- fails. To exclude the root volume, use __ExcludeBootVolume__.
--
-- You can specify up to 40 volume IDs per request.
--
-- 'instanceId', 'instanceSpecification_instanceId' - The instance to specify which volumes should be snapshotted.
newInstanceSpecification ::
  InstanceSpecification
newInstanceSpecification :: InstanceSpecification
newInstanceSpecification =
  InstanceSpecification'
    { $sel:excludeBootVolume:InstanceSpecification' :: Maybe Bool
excludeBootVolume =
        forall a. Maybe a
Prelude.Nothing,
      $sel:excludeDataVolumeIds:InstanceSpecification' :: Maybe [Text]
excludeDataVolumeIds = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:InstanceSpecification' :: Maybe Text
instanceId = forall a. Maybe a
Prelude.Nothing
    }

-- | Excludes the root volume from being snapshotted.
instanceSpecification_excludeBootVolume :: Lens.Lens' InstanceSpecification (Prelude.Maybe Prelude.Bool)
instanceSpecification_excludeBootVolume :: Lens' InstanceSpecification (Maybe Bool)
instanceSpecification_excludeBootVolume = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceSpecification' {Maybe Bool
excludeBootVolume :: Maybe Bool
$sel:excludeBootVolume:InstanceSpecification' :: InstanceSpecification -> Maybe Bool
excludeBootVolume} -> Maybe Bool
excludeBootVolume) (\s :: InstanceSpecification
s@InstanceSpecification' {} Maybe Bool
a -> InstanceSpecification
s {$sel:excludeBootVolume:InstanceSpecification' :: Maybe Bool
excludeBootVolume = Maybe Bool
a} :: InstanceSpecification)

-- | The IDs of the data (non-root) volumes to exclude from the multi-volume
-- snapshot set. If you specify the ID of the root volume, the request
-- fails. To exclude the root volume, use __ExcludeBootVolume__.
--
-- You can specify up to 40 volume IDs per request.
instanceSpecification_excludeDataVolumeIds :: Lens.Lens' InstanceSpecification (Prelude.Maybe [Prelude.Text])
instanceSpecification_excludeDataVolumeIds :: Lens' InstanceSpecification (Maybe [Text])
instanceSpecification_excludeDataVolumeIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceSpecification' {Maybe [Text]
excludeDataVolumeIds :: Maybe [Text]
$sel:excludeDataVolumeIds:InstanceSpecification' :: InstanceSpecification -> Maybe [Text]
excludeDataVolumeIds} -> Maybe [Text]
excludeDataVolumeIds) (\s :: InstanceSpecification
s@InstanceSpecification' {} Maybe [Text]
a -> InstanceSpecification
s {$sel:excludeDataVolumeIds:InstanceSpecification' :: Maybe [Text]
excludeDataVolumeIds = Maybe [Text]
a} :: InstanceSpecification) 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 instance to specify which volumes should be snapshotted.
instanceSpecification_instanceId :: Lens.Lens' InstanceSpecification (Prelude.Maybe Prelude.Text)
instanceSpecification_instanceId :: Lens' InstanceSpecification (Maybe Text)
instanceSpecification_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceSpecification' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:InstanceSpecification' :: InstanceSpecification -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: InstanceSpecification
s@InstanceSpecification' {} Maybe Text
a -> InstanceSpecification
s {$sel:instanceId:InstanceSpecification' :: Maybe Text
instanceId = Maybe Text
a} :: InstanceSpecification)

instance Prelude.Hashable InstanceSpecification where
  hashWithSalt :: Int -> InstanceSpecification -> Int
hashWithSalt Int
_salt InstanceSpecification' {Maybe Bool
Maybe [Text]
Maybe Text
instanceId :: Maybe Text
excludeDataVolumeIds :: Maybe [Text]
excludeBootVolume :: Maybe Bool
$sel:instanceId:InstanceSpecification' :: InstanceSpecification -> Maybe Text
$sel:excludeDataVolumeIds:InstanceSpecification' :: InstanceSpecification -> Maybe [Text]
$sel:excludeBootVolume:InstanceSpecification' :: InstanceSpecification -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
excludeBootVolume
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
excludeDataVolumeIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceId

instance Prelude.NFData InstanceSpecification where
  rnf :: InstanceSpecification -> ()
rnf InstanceSpecification' {Maybe Bool
Maybe [Text]
Maybe Text
instanceId :: Maybe Text
excludeDataVolumeIds :: Maybe [Text]
excludeBootVolume :: Maybe Bool
$sel:instanceId:InstanceSpecification' :: InstanceSpecification -> Maybe Text
$sel:excludeDataVolumeIds:InstanceSpecification' :: InstanceSpecification -> Maybe [Text]
$sel:excludeBootVolume:InstanceSpecification' :: InstanceSpecification -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
excludeBootVolume
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
excludeDataVolumeIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
instanceId

instance Data.ToQuery InstanceSpecification where
  toQuery :: InstanceSpecification -> QueryString
toQuery InstanceSpecification' {Maybe Bool
Maybe [Text]
Maybe Text
instanceId :: Maybe Text
excludeDataVolumeIds :: Maybe [Text]
excludeBootVolume :: Maybe Bool
$sel:instanceId:InstanceSpecification' :: InstanceSpecification -> Maybe Text
$sel:excludeDataVolumeIds:InstanceSpecification' :: InstanceSpecification -> Maybe [Text]
$sel:excludeBootVolume:InstanceSpecification' :: InstanceSpecification -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"ExcludeBootVolume" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
excludeBootVolume,
        forall a. ToQuery a => a -> QueryString
Data.toQuery
          ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"ExcludeDataVolumeId"
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
excludeDataVolumeIds
          ),
        ByteString
"InstanceId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
instanceId
      ]