{-# 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.ImageBuilder.Types.S3ExportConfiguration
-- 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.ImageBuilder.Types.S3ExportConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ImageBuilder.Types.DiskImageFormat
import qualified Amazonka.Prelude as Prelude

-- | Properties that configure export from your build instance to a
-- compatible file format for your VM.
--
-- /See:/ 'newS3ExportConfiguration' smart constructor.
data S3ExportConfiguration = S3ExportConfiguration'
  { -- | The Amazon S3 path for the bucket where the output disk images for your
    -- VM are stored.
    S3ExportConfiguration -> Maybe Text
s3Prefix :: Prelude.Maybe Prelude.Text,
    -- | The name of the role that grants VM Import\/Export permission to export
    -- images to your S3 bucket.
    S3ExportConfiguration -> Text
roleName :: Prelude.Text,
    -- | Export the updated image to one of the following supported disk image
    -- formats:
    --
    -- -   __Virtual Hard Disk (VHD)__ – Compatible with Citrix Xen and
    --     Microsoft Hyper-V virtualization products.
    --
    -- -   __Stream-optimized ESX Virtual Machine Disk (VMDK)__ – Compatible
    --     with VMware ESX and VMware vSphere versions 4, 5, and 6.
    --
    -- -   __Raw__ – Raw format.
    S3ExportConfiguration -> DiskImageFormat
diskImageFormat :: DiskImageFormat,
    -- | The S3 bucket in which to store the output disk images for your VM.
    S3ExportConfiguration -> Text
s3Bucket :: Prelude.Text
  }
  deriving (S3ExportConfiguration -> S3ExportConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3ExportConfiguration -> S3ExportConfiguration -> Bool
$c/= :: S3ExportConfiguration -> S3ExportConfiguration -> Bool
== :: S3ExportConfiguration -> S3ExportConfiguration -> Bool
$c== :: S3ExportConfiguration -> S3ExportConfiguration -> Bool
Prelude.Eq, ReadPrec [S3ExportConfiguration]
ReadPrec S3ExportConfiguration
Int -> ReadS S3ExportConfiguration
ReadS [S3ExportConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3ExportConfiguration]
$creadListPrec :: ReadPrec [S3ExportConfiguration]
readPrec :: ReadPrec S3ExportConfiguration
$creadPrec :: ReadPrec S3ExportConfiguration
readList :: ReadS [S3ExportConfiguration]
$creadList :: ReadS [S3ExportConfiguration]
readsPrec :: Int -> ReadS S3ExportConfiguration
$creadsPrec :: Int -> ReadS S3ExportConfiguration
Prelude.Read, Int -> S3ExportConfiguration -> ShowS
[S3ExportConfiguration] -> ShowS
S3ExportConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3ExportConfiguration] -> ShowS
$cshowList :: [S3ExportConfiguration] -> ShowS
show :: S3ExportConfiguration -> String
$cshow :: S3ExportConfiguration -> String
showsPrec :: Int -> S3ExportConfiguration -> ShowS
$cshowsPrec :: Int -> S3ExportConfiguration -> ShowS
Prelude.Show, forall x. Rep S3ExportConfiguration x -> S3ExportConfiguration
forall x. S3ExportConfiguration -> Rep S3ExportConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3ExportConfiguration x -> S3ExportConfiguration
$cfrom :: forall x. S3ExportConfiguration -> Rep S3ExportConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'S3ExportConfiguration' 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:
--
-- 's3Prefix', 's3ExportConfiguration_s3Prefix' - The Amazon S3 path for the bucket where the output disk images for your
-- VM are stored.
--
-- 'roleName', 's3ExportConfiguration_roleName' - The name of the role that grants VM Import\/Export permission to export
-- images to your S3 bucket.
--
-- 'diskImageFormat', 's3ExportConfiguration_diskImageFormat' - Export the updated image to one of the following supported disk image
-- formats:
--
-- -   __Virtual Hard Disk (VHD)__ – Compatible with Citrix Xen and
--     Microsoft Hyper-V virtualization products.
--
-- -   __Stream-optimized ESX Virtual Machine Disk (VMDK)__ – Compatible
--     with VMware ESX and VMware vSphere versions 4, 5, and 6.
--
-- -   __Raw__ – Raw format.
--
-- 's3Bucket', 's3ExportConfiguration_s3Bucket' - The S3 bucket in which to store the output disk images for your VM.
newS3ExportConfiguration ::
  -- | 'roleName'
  Prelude.Text ->
  -- | 'diskImageFormat'
  DiskImageFormat ->
  -- | 's3Bucket'
  Prelude.Text ->
  S3ExportConfiguration
newS3ExportConfiguration :: Text -> DiskImageFormat -> Text -> S3ExportConfiguration
newS3ExportConfiguration
  Text
pRoleName_
  DiskImageFormat
pDiskImageFormat_
  Text
pS3Bucket_ =
    S3ExportConfiguration'
      { $sel:s3Prefix:S3ExportConfiguration' :: Maybe Text
s3Prefix = forall a. Maybe a
Prelude.Nothing,
        $sel:roleName:S3ExportConfiguration' :: Text
roleName = Text
pRoleName_,
        $sel:diskImageFormat:S3ExportConfiguration' :: DiskImageFormat
diskImageFormat = DiskImageFormat
pDiskImageFormat_,
        $sel:s3Bucket:S3ExportConfiguration' :: Text
s3Bucket = Text
pS3Bucket_
      }

-- | The Amazon S3 path for the bucket where the output disk images for your
-- VM are stored.
s3ExportConfiguration_s3Prefix :: Lens.Lens' S3ExportConfiguration (Prelude.Maybe Prelude.Text)
s3ExportConfiguration_s3Prefix :: Lens' S3ExportConfiguration (Maybe Text)
s3ExportConfiguration_s3Prefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ExportConfiguration' {Maybe Text
s3Prefix :: Maybe Text
$sel:s3Prefix:S3ExportConfiguration' :: S3ExportConfiguration -> Maybe Text
s3Prefix} -> Maybe Text
s3Prefix) (\s :: S3ExportConfiguration
s@S3ExportConfiguration' {} Maybe Text
a -> S3ExportConfiguration
s {$sel:s3Prefix:S3ExportConfiguration' :: Maybe Text
s3Prefix = Maybe Text
a} :: S3ExportConfiguration)

-- | The name of the role that grants VM Import\/Export permission to export
-- images to your S3 bucket.
s3ExportConfiguration_roleName :: Lens.Lens' S3ExportConfiguration Prelude.Text
s3ExportConfiguration_roleName :: Lens' S3ExportConfiguration Text
s3ExportConfiguration_roleName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ExportConfiguration' {Text
roleName :: Text
$sel:roleName:S3ExportConfiguration' :: S3ExportConfiguration -> Text
roleName} -> Text
roleName) (\s :: S3ExportConfiguration
s@S3ExportConfiguration' {} Text
a -> S3ExportConfiguration
s {$sel:roleName:S3ExportConfiguration' :: Text
roleName = Text
a} :: S3ExportConfiguration)

-- | Export the updated image to one of the following supported disk image
-- formats:
--
-- -   __Virtual Hard Disk (VHD)__ – Compatible with Citrix Xen and
--     Microsoft Hyper-V virtualization products.
--
-- -   __Stream-optimized ESX Virtual Machine Disk (VMDK)__ – Compatible
--     with VMware ESX and VMware vSphere versions 4, 5, and 6.
--
-- -   __Raw__ – Raw format.
s3ExportConfiguration_diskImageFormat :: Lens.Lens' S3ExportConfiguration DiskImageFormat
s3ExportConfiguration_diskImageFormat :: Lens' S3ExportConfiguration DiskImageFormat
s3ExportConfiguration_diskImageFormat = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ExportConfiguration' {DiskImageFormat
diskImageFormat :: DiskImageFormat
$sel:diskImageFormat:S3ExportConfiguration' :: S3ExportConfiguration -> DiskImageFormat
diskImageFormat} -> DiskImageFormat
diskImageFormat) (\s :: S3ExportConfiguration
s@S3ExportConfiguration' {} DiskImageFormat
a -> S3ExportConfiguration
s {$sel:diskImageFormat:S3ExportConfiguration' :: DiskImageFormat
diskImageFormat = DiskImageFormat
a} :: S3ExportConfiguration)

-- | The S3 bucket in which to store the output disk images for your VM.
s3ExportConfiguration_s3Bucket :: Lens.Lens' S3ExportConfiguration Prelude.Text
s3ExportConfiguration_s3Bucket :: Lens' S3ExportConfiguration Text
s3ExportConfiguration_s3Bucket = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ExportConfiguration' {Text
s3Bucket :: Text
$sel:s3Bucket:S3ExportConfiguration' :: S3ExportConfiguration -> Text
s3Bucket} -> Text
s3Bucket) (\s :: S3ExportConfiguration
s@S3ExportConfiguration' {} Text
a -> S3ExportConfiguration
s {$sel:s3Bucket:S3ExportConfiguration' :: Text
s3Bucket = Text
a} :: S3ExportConfiguration)

instance Data.FromJSON S3ExportConfiguration where
  parseJSON :: Value -> Parser S3ExportConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3ExportConfiguration"
      ( \Object
x ->
          Maybe Text
-> Text -> DiskImageFormat -> Text -> S3ExportConfiguration
S3ExportConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"s3Prefix")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"roleName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"diskImageFormat")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"s3Bucket")
      )

instance Prelude.Hashable S3ExportConfiguration where
  hashWithSalt :: Int -> S3ExportConfiguration -> Int
hashWithSalt Int
_salt S3ExportConfiguration' {Maybe Text
Text
DiskImageFormat
s3Bucket :: Text
diskImageFormat :: DiskImageFormat
roleName :: Text
s3Prefix :: Maybe Text
$sel:s3Bucket:S3ExportConfiguration' :: S3ExportConfiguration -> Text
$sel:diskImageFormat:S3ExportConfiguration' :: S3ExportConfiguration -> DiskImageFormat
$sel:roleName:S3ExportConfiguration' :: S3ExportConfiguration -> Text
$sel:s3Prefix:S3ExportConfiguration' :: S3ExportConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
s3Prefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DiskImageFormat
diskImageFormat
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3Bucket

instance Prelude.NFData S3ExportConfiguration where
  rnf :: S3ExportConfiguration -> ()
rnf S3ExportConfiguration' {Maybe Text
Text
DiskImageFormat
s3Bucket :: Text
diskImageFormat :: DiskImageFormat
roleName :: Text
s3Prefix :: Maybe Text
$sel:s3Bucket:S3ExportConfiguration' :: S3ExportConfiguration -> Text
$sel:diskImageFormat:S3ExportConfiguration' :: S3ExportConfiguration -> DiskImageFormat
$sel:roleName:S3ExportConfiguration' :: S3ExportConfiguration -> Text
$sel:s3Prefix:S3ExportConfiguration' :: S3ExportConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s3Prefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DiskImageFormat
diskImageFormat
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
s3Bucket

instance Data.ToJSON S3ExportConfiguration where
  toJSON :: S3ExportConfiguration -> Value
toJSON S3ExportConfiguration' {Maybe Text
Text
DiskImageFormat
s3Bucket :: Text
diskImageFormat :: DiskImageFormat
roleName :: Text
s3Prefix :: Maybe Text
$sel:s3Bucket:S3ExportConfiguration' :: S3ExportConfiguration -> Text
$sel:diskImageFormat:S3ExportConfiguration' :: S3ExportConfiguration -> DiskImageFormat
$sel:roleName:S3ExportConfiguration' :: S3ExportConfiguration -> Text
$sel:s3Prefix:S3ExportConfiguration' :: S3ExportConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"s3Prefix" 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
s3Prefix,
            forall a. a -> Maybe a
Prelude.Just (Key
"roleName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
roleName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"diskImageFormat" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DiskImageFormat
diskImageFormat),
            forall a. a -> Maybe a
Prelude.Just (Key
"s3Bucket" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3Bucket)
          ]
      )