{-# 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.ImageBuilder.ImportVmImage
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- When you export your virtual machine (VM) from its virtualization
-- environment, that process creates a set of one or more disk container
-- files that act as snapshots of your VM’s environment, settings, and
-- data. The Amazon EC2 API
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ImportImage.html ImportImage>
-- action uses those files to import your VM and create an AMI. To import
-- using the CLI command, see
-- <https://docs.aws.amazon.com/cli/latest/reference/ec2/import-image.html import-image>
--
-- You can reference the task ID from the VM import to pull in the AMI that
-- the import created as the base image for your Image Builder recipe.
module Amazonka.ImageBuilder.ImportVmImage
  ( -- * Creating a Request
    ImportVmImage (..),
    newImportVmImage,

    -- * Request Lenses
    importVmImage_description,
    importVmImage_osVersion,
    importVmImage_tags,
    importVmImage_name,
    importVmImage_semanticVersion,
    importVmImage_platform,
    importVmImage_vmImportTaskId,
    importVmImage_clientToken,

    -- * Destructuring the Response
    ImportVmImageResponse (..),
    newImportVmImageResponse,

    -- * Response Lenses
    importVmImageResponse_clientToken,
    importVmImageResponse_imageArn,
    importVmImageResponse_requestId,
    importVmImageResponse_httpStatus,
  )
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
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newImportVmImage' smart constructor.
data ImportVmImage = ImportVmImage'
  { -- | The description for the base image that is created by the import
    -- process.
    ImportVmImage -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The operating system version for the imported VM.
    ImportVmImage -> Maybe Text
osVersion :: Prelude.Maybe Prelude.Text,
    -- | Tags that are attached to the import resources.
    ImportVmImage -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the base image that is created by the import process.
    ImportVmImage -> Text
name :: Prelude.Text,
    -- | The semantic version to attach to the base image that was created during
    -- the import process. This version follows the semantic version syntax.
    --
    -- The semantic version has four nodes:
    -- \<major>.\<minor>.\<patch>\/\<build>. You can assign values for the
    -- first three, and can filter on all of them.
    --
    -- __Assignment:__ For the first three nodes you can assign any positive
    -- integer value, including zero, with an upper limit of 2^30-1, or
    -- 1073741823 for each node. Image Builder automatically assigns the build
    -- number to the fourth node.
    --
    -- __Patterns:__ You can use any numeric pattern that adheres to the
    -- assignment requirements for the nodes that you can assign. For example,
    -- you might choose a software version pattern, such as 1.0.0, or a date,
    -- such as 2021.01.01.
    ImportVmImage -> Text
semanticVersion :: Prelude.Text,
    -- | The operating system platform for the imported VM.
    ImportVmImage -> Platform
platform :: Platform,
    -- | The @importTaskId@ (API) or @ImportTaskId@ (CLI) from the Amazon EC2 VM
    -- import process. Image Builder retrieves information from the import
    -- process to pull in the AMI that is created from the VM source as the
    -- base image for your recipe.
    ImportVmImage -> Text
vmImportTaskId :: Prelude.Text,
    -- | Unique, case-sensitive identifier you provide to ensure idempotency of
    -- the request. For more information, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html Ensuring idempotency>
    -- in the /Amazon EC2 API Reference/.
    ImportVmImage -> Text
clientToken :: Prelude.Text
  }
  deriving (ImportVmImage -> ImportVmImage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportVmImage -> ImportVmImage -> Bool
$c/= :: ImportVmImage -> ImportVmImage -> Bool
== :: ImportVmImage -> ImportVmImage -> Bool
$c== :: ImportVmImage -> ImportVmImage -> Bool
Prelude.Eq, ReadPrec [ImportVmImage]
ReadPrec ImportVmImage
Int -> ReadS ImportVmImage
ReadS [ImportVmImage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportVmImage]
$creadListPrec :: ReadPrec [ImportVmImage]
readPrec :: ReadPrec ImportVmImage
$creadPrec :: ReadPrec ImportVmImage
readList :: ReadS [ImportVmImage]
$creadList :: ReadS [ImportVmImage]
readsPrec :: Int -> ReadS ImportVmImage
$creadsPrec :: Int -> ReadS ImportVmImage
Prelude.Read, Int -> ImportVmImage -> ShowS
[ImportVmImage] -> ShowS
ImportVmImage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportVmImage] -> ShowS
$cshowList :: [ImportVmImage] -> ShowS
show :: ImportVmImage -> String
$cshow :: ImportVmImage -> String
showsPrec :: Int -> ImportVmImage -> ShowS
$cshowsPrec :: Int -> ImportVmImage -> ShowS
Prelude.Show, forall x. Rep ImportVmImage x -> ImportVmImage
forall x. ImportVmImage -> Rep ImportVmImage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImportVmImage x -> ImportVmImage
$cfrom :: forall x. ImportVmImage -> Rep ImportVmImage x
Prelude.Generic)

-- |
-- Create a value of 'ImportVmImage' 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:
--
-- 'description', 'importVmImage_description' - The description for the base image that is created by the import
-- process.
--
-- 'osVersion', 'importVmImage_osVersion' - The operating system version for the imported VM.
--
-- 'tags', 'importVmImage_tags' - Tags that are attached to the import resources.
--
-- 'name', 'importVmImage_name' - The name of the base image that is created by the import process.
--
-- 'semanticVersion', 'importVmImage_semanticVersion' - The semantic version to attach to the base image that was created during
-- the import process. This version follows the semantic version syntax.
--
-- The semantic version has four nodes:
-- \<major>.\<minor>.\<patch>\/\<build>. You can assign values for the
-- first three, and can filter on all of them.
--
-- __Assignment:__ For the first three nodes you can assign any positive
-- integer value, including zero, with an upper limit of 2^30-1, or
-- 1073741823 for each node. Image Builder automatically assigns the build
-- number to the fourth node.
--
-- __Patterns:__ You can use any numeric pattern that adheres to the
-- assignment requirements for the nodes that you can assign. For example,
-- you might choose a software version pattern, such as 1.0.0, or a date,
-- such as 2021.01.01.
--
-- 'platform', 'importVmImage_platform' - The operating system platform for the imported VM.
--
-- 'vmImportTaskId', 'importVmImage_vmImportTaskId' - The @importTaskId@ (API) or @ImportTaskId@ (CLI) from the Amazon EC2 VM
-- import process. Image Builder retrieves information from the import
-- process to pull in the AMI that is created from the VM source as the
-- base image for your recipe.
--
-- 'clientToken', 'importVmImage_clientToken' - Unique, case-sensitive identifier you provide to ensure idempotency of
-- the request. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html Ensuring idempotency>
-- in the /Amazon EC2 API Reference/.
newImportVmImage ::
  -- | 'name'
  Prelude.Text ->
  -- | 'semanticVersion'
  Prelude.Text ->
  -- | 'platform'
  Platform ->
  -- | 'vmImportTaskId'
  Prelude.Text ->
  -- | 'clientToken'
  Prelude.Text ->
  ImportVmImage
newImportVmImage :: Text -> Text -> Platform -> Text -> Text -> ImportVmImage
newImportVmImage
  Text
pName_
  Text
pSemanticVersion_
  Platform
pPlatform_
  Text
pVmImportTaskId_
  Text
pClientToken_ =
    ImportVmImage'
      { $sel:description:ImportVmImage' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
        $sel:osVersion:ImportVmImage' :: Maybe Text
osVersion = forall a. Maybe a
Prelude.Nothing,
        $sel:tags:ImportVmImage' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
        $sel:name:ImportVmImage' :: Text
name = Text
pName_,
        $sel:semanticVersion:ImportVmImage' :: Text
semanticVersion = Text
pSemanticVersion_,
        $sel:platform:ImportVmImage' :: Platform
platform = Platform
pPlatform_,
        $sel:vmImportTaskId:ImportVmImage' :: Text
vmImportTaskId = Text
pVmImportTaskId_,
        $sel:clientToken:ImportVmImage' :: Text
clientToken = Text
pClientToken_
      }

-- | The description for the base image that is created by the import
-- process.
importVmImage_description :: Lens.Lens' ImportVmImage (Prelude.Maybe Prelude.Text)
importVmImage_description :: Lens' ImportVmImage (Maybe Text)
importVmImage_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportVmImage' {Maybe Text
description :: Maybe Text
$sel:description:ImportVmImage' :: ImportVmImage -> Maybe Text
description} -> Maybe Text
description) (\s :: ImportVmImage
s@ImportVmImage' {} Maybe Text
a -> ImportVmImage
s {$sel:description:ImportVmImage' :: Maybe Text
description = Maybe Text
a} :: ImportVmImage)

-- | The operating system version for the imported VM.
importVmImage_osVersion :: Lens.Lens' ImportVmImage (Prelude.Maybe Prelude.Text)
importVmImage_osVersion :: Lens' ImportVmImage (Maybe Text)
importVmImage_osVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportVmImage' {Maybe Text
osVersion :: Maybe Text
$sel:osVersion:ImportVmImage' :: ImportVmImage -> Maybe Text
osVersion} -> Maybe Text
osVersion) (\s :: ImportVmImage
s@ImportVmImage' {} Maybe Text
a -> ImportVmImage
s {$sel:osVersion:ImportVmImage' :: Maybe Text
osVersion = Maybe Text
a} :: ImportVmImage)

-- | Tags that are attached to the import resources.
importVmImage_tags :: Lens.Lens' ImportVmImage (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
importVmImage_tags :: Lens' ImportVmImage (Maybe (HashMap Text Text))
importVmImage_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportVmImage' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:ImportVmImage' :: ImportVmImage -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: ImportVmImage
s@ImportVmImage' {} Maybe (HashMap Text Text)
a -> ImportVmImage
s {$sel:tags:ImportVmImage' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: ImportVmImage) 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 name of the base image that is created by the import process.
importVmImage_name :: Lens.Lens' ImportVmImage Prelude.Text
importVmImage_name :: Lens' ImportVmImage Text
importVmImage_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportVmImage' {Text
name :: Text
$sel:name:ImportVmImage' :: ImportVmImage -> Text
name} -> Text
name) (\s :: ImportVmImage
s@ImportVmImage' {} Text
a -> ImportVmImage
s {$sel:name:ImportVmImage' :: Text
name = Text
a} :: ImportVmImage)

-- | The semantic version to attach to the base image that was created during
-- the import process. This version follows the semantic version syntax.
--
-- The semantic version has four nodes:
-- \<major>.\<minor>.\<patch>\/\<build>. You can assign values for the
-- first three, and can filter on all of them.
--
-- __Assignment:__ For the first three nodes you can assign any positive
-- integer value, including zero, with an upper limit of 2^30-1, or
-- 1073741823 for each node. Image Builder automatically assigns the build
-- number to the fourth node.
--
-- __Patterns:__ You can use any numeric pattern that adheres to the
-- assignment requirements for the nodes that you can assign. For example,
-- you might choose a software version pattern, such as 1.0.0, or a date,
-- such as 2021.01.01.
importVmImage_semanticVersion :: Lens.Lens' ImportVmImage Prelude.Text
importVmImage_semanticVersion :: Lens' ImportVmImage Text
importVmImage_semanticVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportVmImage' {Text
semanticVersion :: Text
$sel:semanticVersion:ImportVmImage' :: ImportVmImage -> Text
semanticVersion} -> Text
semanticVersion) (\s :: ImportVmImage
s@ImportVmImage' {} Text
a -> ImportVmImage
s {$sel:semanticVersion:ImportVmImage' :: Text
semanticVersion = Text
a} :: ImportVmImage)

-- | The operating system platform for the imported VM.
importVmImage_platform :: Lens.Lens' ImportVmImage Platform
importVmImage_platform :: Lens' ImportVmImage Platform
importVmImage_platform = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportVmImage' {Platform
platform :: Platform
$sel:platform:ImportVmImage' :: ImportVmImage -> Platform
platform} -> Platform
platform) (\s :: ImportVmImage
s@ImportVmImage' {} Platform
a -> ImportVmImage
s {$sel:platform:ImportVmImage' :: Platform
platform = Platform
a} :: ImportVmImage)

-- | The @importTaskId@ (API) or @ImportTaskId@ (CLI) from the Amazon EC2 VM
-- import process. Image Builder retrieves information from the import
-- process to pull in the AMI that is created from the VM source as the
-- base image for your recipe.
importVmImage_vmImportTaskId :: Lens.Lens' ImportVmImage Prelude.Text
importVmImage_vmImportTaskId :: Lens' ImportVmImage Text
importVmImage_vmImportTaskId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportVmImage' {Text
vmImportTaskId :: Text
$sel:vmImportTaskId:ImportVmImage' :: ImportVmImage -> Text
vmImportTaskId} -> Text
vmImportTaskId) (\s :: ImportVmImage
s@ImportVmImage' {} Text
a -> ImportVmImage
s {$sel:vmImportTaskId:ImportVmImage' :: Text
vmImportTaskId = Text
a} :: ImportVmImage)

-- | Unique, case-sensitive identifier you provide to ensure idempotency of
-- the request. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html Ensuring idempotency>
-- in the /Amazon EC2 API Reference/.
importVmImage_clientToken :: Lens.Lens' ImportVmImage Prelude.Text
importVmImage_clientToken :: Lens' ImportVmImage Text
importVmImage_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportVmImage' {Text
clientToken :: Text
$sel:clientToken:ImportVmImage' :: ImportVmImage -> Text
clientToken} -> Text
clientToken) (\s :: ImportVmImage
s@ImportVmImage' {} Text
a -> ImportVmImage
s {$sel:clientToken:ImportVmImage' :: Text
clientToken = Text
a} :: ImportVmImage)

instance Core.AWSRequest ImportVmImage where
  type
    AWSResponse ImportVmImage =
      ImportVmImageResponse
  request :: (Service -> Service) -> ImportVmImage -> Request ImportVmImage
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ImportVmImage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ImportVmImage)))
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 Text
-> Maybe Text -> Maybe Text -> Int -> ImportVmImageResponse
ImportVmImageResponse'
            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
"clientToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"imageArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"requestId")
            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 ImportVmImage where
  hashWithSalt :: Int -> ImportVmImage -> Int
hashWithSalt Int
_salt ImportVmImage' {Maybe Text
Maybe (HashMap Text Text)
Text
Platform
clientToken :: Text
vmImportTaskId :: Text
platform :: Platform
semanticVersion :: Text
name :: Text
tags :: Maybe (HashMap Text Text)
osVersion :: Maybe Text
description :: Maybe Text
$sel:clientToken:ImportVmImage' :: ImportVmImage -> Text
$sel:vmImportTaskId:ImportVmImage' :: ImportVmImage -> Text
$sel:platform:ImportVmImage' :: ImportVmImage -> Platform
$sel:semanticVersion:ImportVmImage' :: ImportVmImage -> Text
$sel:name:ImportVmImage' :: ImportVmImage -> Text
$sel:tags:ImportVmImage' :: ImportVmImage -> Maybe (HashMap Text Text)
$sel:osVersion:ImportVmImage' :: ImportVmImage -> Maybe Text
$sel:description:ImportVmImage' :: ImportVmImage -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
osVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
semanticVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Platform
platform
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
vmImportTaskId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clientToken

instance Prelude.NFData ImportVmImage where
  rnf :: ImportVmImage -> ()
rnf ImportVmImage' {Maybe Text
Maybe (HashMap Text Text)
Text
Platform
clientToken :: Text
vmImportTaskId :: Text
platform :: Platform
semanticVersion :: Text
name :: Text
tags :: Maybe (HashMap Text Text)
osVersion :: Maybe Text
description :: Maybe Text
$sel:clientToken:ImportVmImage' :: ImportVmImage -> Text
$sel:vmImportTaskId:ImportVmImage' :: ImportVmImage -> Text
$sel:platform:ImportVmImage' :: ImportVmImage -> Platform
$sel:semanticVersion:ImportVmImage' :: ImportVmImage -> Text
$sel:name:ImportVmImage' :: ImportVmImage -> Text
$sel:tags:ImportVmImage' :: ImportVmImage -> Maybe (HashMap Text Text)
$sel:osVersion:ImportVmImage' :: ImportVmImage -> Maybe Text
$sel:description:ImportVmImage' :: ImportVmImage -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
osVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
semanticVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Platform
platform
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
vmImportTaskId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
clientToken

instance Data.ToHeaders ImportVmImage where
  toHeaders :: ImportVmImage -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ImportVmImage where
  toJSON :: ImportVmImage -> Value
toJSON ImportVmImage' {Maybe Text
Maybe (HashMap Text Text)
Text
Platform
clientToken :: Text
vmImportTaskId :: Text
platform :: Platform
semanticVersion :: Text
name :: Text
tags :: Maybe (HashMap Text Text)
osVersion :: Maybe Text
description :: Maybe Text
$sel:clientToken:ImportVmImage' :: ImportVmImage -> Text
$sel:vmImportTaskId:ImportVmImage' :: ImportVmImage -> Text
$sel:platform:ImportVmImage' :: ImportVmImage -> Platform
$sel:semanticVersion:ImportVmImage' :: ImportVmImage -> Text
$sel:name:ImportVmImage' :: ImportVmImage -> Text
$sel:tags:ImportVmImage' :: ImportVmImage -> Maybe (HashMap Text Text)
$sel:osVersion:ImportVmImage' :: ImportVmImage -> Maybe Text
$sel:description:ImportVmImage' :: ImportVmImage -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"description" 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
description,
            (Key
"osVersion" 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
osVersion,
            (Key
"tags" 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 (HashMap Text Text)
tags,
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"semanticVersion" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
semanticVersion),
            forall a. a -> Maybe a
Prelude.Just (Key
"platform" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Platform
platform),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"vmImportTaskId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
vmImportTaskId),
            forall a. a -> Maybe a
Prelude.Just (Key
"clientToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
clientToken)
          ]
      )

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

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

-- | /See:/ 'newImportVmImageResponse' smart constructor.
data ImportVmImageResponse = ImportVmImageResponse'
  { -- | The idempotency token that was used for this request.
    ImportVmImageResponse -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the AMI that was created during the VM
    -- import process. This AMI is used as the base image for the recipe that
    -- imported the VM.
    ImportVmImageResponse -> Maybe Text
imageArn :: Prelude.Maybe Prelude.Text,
    -- | The request ID that uniquely identifies this request.
    ImportVmImageResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ImportVmImageResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ImportVmImageResponse -> ImportVmImageResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportVmImageResponse -> ImportVmImageResponse -> Bool
$c/= :: ImportVmImageResponse -> ImportVmImageResponse -> Bool
== :: ImportVmImageResponse -> ImportVmImageResponse -> Bool
$c== :: ImportVmImageResponse -> ImportVmImageResponse -> Bool
Prelude.Eq, ReadPrec [ImportVmImageResponse]
ReadPrec ImportVmImageResponse
Int -> ReadS ImportVmImageResponse
ReadS [ImportVmImageResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportVmImageResponse]
$creadListPrec :: ReadPrec [ImportVmImageResponse]
readPrec :: ReadPrec ImportVmImageResponse
$creadPrec :: ReadPrec ImportVmImageResponse
readList :: ReadS [ImportVmImageResponse]
$creadList :: ReadS [ImportVmImageResponse]
readsPrec :: Int -> ReadS ImportVmImageResponse
$creadsPrec :: Int -> ReadS ImportVmImageResponse
Prelude.Read, Int -> ImportVmImageResponse -> ShowS
[ImportVmImageResponse] -> ShowS
ImportVmImageResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportVmImageResponse] -> ShowS
$cshowList :: [ImportVmImageResponse] -> ShowS
show :: ImportVmImageResponse -> String
$cshow :: ImportVmImageResponse -> String
showsPrec :: Int -> ImportVmImageResponse -> ShowS
$cshowsPrec :: Int -> ImportVmImageResponse -> ShowS
Prelude.Show, forall x. Rep ImportVmImageResponse x -> ImportVmImageResponse
forall x. ImportVmImageResponse -> Rep ImportVmImageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImportVmImageResponse x -> ImportVmImageResponse
$cfrom :: forall x. ImportVmImageResponse -> Rep ImportVmImageResponse x
Prelude.Generic)

-- |
-- Create a value of 'ImportVmImageResponse' 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:
--
-- 'clientToken', 'importVmImageResponse_clientToken' - The idempotency token that was used for this request.
--
-- 'imageArn', 'importVmImageResponse_imageArn' - The Amazon Resource Name (ARN) of the AMI that was created during the VM
-- import process. This AMI is used as the base image for the recipe that
-- imported the VM.
--
-- 'requestId', 'importVmImageResponse_requestId' - The request ID that uniquely identifies this request.
--
-- 'httpStatus', 'importVmImageResponse_httpStatus' - The response's http status code.
newImportVmImageResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ImportVmImageResponse
newImportVmImageResponse :: Int -> ImportVmImageResponse
newImportVmImageResponse Int
pHttpStatus_ =
  ImportVmImageResponse'
    { $sel:clientToken:ImportVmImageResponse' :: Maybe Text
clientToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:imageArn:ImportVmImageResponse' :: Maybe Text
imageArn = forall a. Maybe a
Prelude.Nothing,
      $sel:requestId:ImportVmImageResponse' :: Maybe Text
requestId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ImportVmImageResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The idempotency token that was used for this request.
importVmImageResponse_clientToken :: Lens.Lens' ImportVmImageResponse (Prelude.Maybe Prelude.Text)
importVmImageResponse_clientToken :: Lens' ImportVmImageResponse (Maybe Text)
importVmImageResponse_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportVmImageResponse' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:ImportVmImageResponse' :: ImportVmImageResponse -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: ImportVmImageResponse
s@ImportVmImageResponse' {} Maybe Text
a -> ImportVmImageResponse
s {$sel:clientToken:ImportVmImageResponse' :: Maybe Text
clientToken = Maybe Text
a} :: ImportVmImageResponse)

-- | The Amazon Resource Name (ARN) of the AMI that was created during the VM
-- import process. This AMI is used as the base image for the recipe that
-- imported the VM.
importVmImageResponse_imageArn :: Lens.Lens' ImportVmImageResponse (Prelude.Maybe Prelude.Text)
importVmImageResponse_imageArn :: Lens' ImportVmImageResponse (Maybe Text)
importVmImageResponse_imageArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportVmImageResponse' {Maybe Text
imageArn :: Maybe Text
$sel:imageArn:ImportVmImageResponse' :: ImportVmImageResponse -> Maybe Text
imageArn} -> Maybe Text
imageArn) (\s :: ImportVmImageResponse
s@ImportVmImageResponse' {} Maybe Text
a -> ImportVmImageResponse
s {$sel:imageArn:ImportVmImageResponse' :: Maybe Text
imageArn = Maybe Text
a} :: ImportVmImageResponse)

-- | The request ID that uniquely identifies this request.
importVmImageResponse_requestId :: Lens.Lens' ImportVmImageResponse (Prelude.Maybe Prelude.Text)
importVmImageResponse_requestId :: Lens' ImportVmImageResponse (Maybe Text)
importVmImageResponse_requestId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportVmImageResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:ImportVmImageResponse' :: ImportVmImageResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: ImportVmImageResponse
s@ImportVmImageResponse' {} Maybe Text
a -> ImportVmImageResponse
s {$sel:requestId:ImportVmImageResponse' :: Maybe Text
requestId = Maybe Text
a} :: ImportVmImageResponse)

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

instance Prelude.NFData ImportVmImageResponse where
  rnf :: ImportVmImageResponse -> ()
rnf ImportVmImageResponse' {Int
Maybe Text
httpStatus :: Int
requestId :: Maybe Text
imageArn :: Maybe Text
clientToken :: Maybe Text
$sel:httpStatus:ImportVmImageResponse' :: ImportVmImageResponse -> Int
$sel:requestId:ImportVmImageResponse' :: ImportVmImageResponse -> Maybe Text
$sel:imageArn:ImportVmImageResponse' :: ImportVmImageResponse -> Maybe Text
$sel:clientToken:ImportVmImageResponse' :: ImportVmImageResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
imageArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
requestId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus