{-# 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.GreengrassV2.CreateComponentVersion
-- 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)
--
-- Creates a component. Components are software that run on Greengrass core
-- devices. After you develop and test a component on your core device, you
-- can use this operation to upload your component to IoT Greengrass. Then,
-- you can deploy the component to other core devices.
--
-- You can use this operation to do the following:
--
-- -   __Create components from recipes__
--
--     Create a component from a recipe, which is a file that defines the
--     component\'s metadata, parameters, dependencies, lifecycle,
--     artifacts, and platform capability. For more information, see
--     <https://docs.aws.amazon.com/greengrass/v2/developerguide/component-recipe-reference.html IoT Greengrass component recipe reference>
--     in the /IoT Greengrass V2 Developer Guide/.
--
--     To create a component from a recipe, specify @inlineRecipe@ when you
--     call this operation.
--
-- -   __Create components from Lambda functions__
--
--     Create a component from an Lambda function that runs on IoT
--     Greengrass. This creates a recipe and artifacts from the Lambda
--     function\'s deployment package. You can use this operation to
--     migrate Lambda functions from IoT Greengrass V1 to IoT Greengrass
--     V2.
--
--     This function only accepts Lambda functions that use the following
--     runtimes:
--
--     -   Python 2.7 – @python2.7@
--
--     -   Python 3.7 – @python3.7@
--
--     -   Python 3.8 – @python3.8@
--
--     -   Java 8 – @java8@
--
--     -   Node.js 10 – @nodejs10.x@
--
--     -   Node.js 12 – @nodejs12.x@
--
--     To create a component from a Lambda function, specify
--     @lambdaFunction@ when you call this operation.
module Amazonka.GreengrassV2.CreateComponentVersion
  ( -- * Creating a Request
    CreateComponentVersion (..),
    newCreateComponentVersion,

    -- * Request Lenses
    createComponentVersion_clientToken,
    createComponentVersion_inlineRecipe,
    createComponentVersion_lambdaFunction,
    createComponentVersion_tags,

    -- * Destructuring the Response
    CreateComponentVersionResponse (..),
    newCreateComponentVersionResponse,

    -- * Response Lenses
    createComponentVersionResponse_arn,
    createComponentVersionResponse_httpStatus,
    createComponentVersionResponse_componentName,
    createComponentVersionResponse_componentVersion,
    createComponentVersionResponse_creationTimestamp,
    createComponentVersionResponse_status,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GreengrassV2.Types
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:/ 'newCreateComponentVersion' smart constructor.
data CreateComponentVersion = CreateComponentVersion'
  { -- | A unique, case-sensitive identifier that you can provide to ensure that
    -- the request is idempotent. Idempotency means that the request is
    -- successfully processed only once, even if you send the request multiple
    -- times. When a request succeeds, and you specify the same client token
    -- for subsequent successful requests, the IoT Greengrass V2 service
    -- returns the successful response that it caches from the previous
    -- request. IoT Greengrass V2 caches successful responses for idempotent
    -- requests for up to 8 hours.
    CreateComponentVersion -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The recipe to use to create the component. The recipe defines the
    -- component\'s metadata, parameters, dependencies, lifecycle, artifacts,
    -- and platform compatibility.
    --
    -- You must specify either @inlineRecipe@ or @lambdaFunction@.
    CreateComponentVersion -> Maybe Base64
inlineRecipe :: Prelude.Maybe Core.Base64,
    -- | The parameters to create a component from a Lambda function.
    --
    -- You must specify either @inlineRecipe@ or @lambdaFunction@.
    CreateComponentVersion -> Maybe LambdaFunctionRecipeSource
lambdaFunction :: Prelude.Maybe LambdaFunctionRecipeSource,
    -- | A list of key-value pairs that contain metadata for the resource. For
    -- more information, see
    -- <https://docs.aws.amazon.com/greengrass/v2/developerguide/tag-resources.html Tag your resources>
    -- in the /IoT Greengrass V2 Developer Guide/.
    CreateComponentVersion -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (CreateComponentVersion -> CreateComponentVersion -> Bool
(CreateComponentVersion -> CreateComponentVersion -> Bool)
-> (CreateComponentVersion -> CreateComponentVersion -> Bool)
-> Eq CreateComponentVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateComponentVersion -> CreateComponentVersion -> Bool
$c/= :: CreateComponentVersion -> CreateComponentVersion -> Bool
== :: CreateComponentVersion -> CreateComponentVersion -> Bool
$c== :: CreateComponentVersion -> CreateComponentVersion -> Bool
Prelude.Eq, ReadPrec [CreateComponentVersion]
ReadPrec CreateComponentVersion
Int -> ReadS CreateComponentVersion
ReadS [CreateComponentVersion]
(Int -> ReadS CreateComponentVersion)
-> ReadS [CreateComponentVersion]
-> ReadPrec CreateComponentVersion
-> ReadPrec [CreateComponentVersion]
-> Read CreateComponentVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateComponentVersion]
$creadListPrec :: ReadPrec [CreateComponentVersion]
readPrec :: ReadPrec CreateComponentVersion
$creadPrec :: ReadPrec CreateComponentVersion
readList :: ReadS [CreateComponentVersion]
$creadList :: ReadS [CreateComponentVersion]
readsPrec :: Int -> ReadS CreateComponentVersion
$creadsPrec :: Int -> ReadS CreateComponentVersion
Prelude.Read, Int -> CreateComponentVersion -> ShowS
[CreateComponentVersion] -> ShowS
CreateComponentVersion -> String
(Int -> CreateComponentVersion -> ShowS)
-> (CreateComponentVersion -> String)
-> ([CreateComponentVersion] -> ShowS)
-> Show CreateComponentVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateComponentVersion] -> ShowS
$cshowList :: [CreateComponentVersion] -> ShowS
show :: CreateComponentVersion -> String
$cshow :: CreateComponentVersion -> String
showsPrec :: Int -> CreateComponentVersion -> ShowS
$cshowsPrec :: Int -> CreateComponentVersion -> ShowS
Prelude.Show, (forall x. CreateComponentVersion -> Rep CreateComponentVersion x)
-> (forall x.
    Rep CreateComponentVersion x -> CreateComponentVersion)
-> Generic CreateComponentVersion
forall x. Rep CreateComponentVersion x -> CreateComponentVersion
forall x. CreateComponentVersion -> Rep CreateComponentVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateComponentVersion x -> CreateComponentVersion
$cfrom :: forall x. CreateComponentVersion -> Rep CreateComponentVersion x
Prelude.Generic)

-- |
-- Create a value of 'CreateComponentVersion' 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', 'createComponentVersion_clientToken' - A unique, case-sensitive identifier that you can provide to ensure that
-- the request is idempotent. Idempotency means that the request is
-- successfully processed only once, even if you send the request multiple
-- times. When a request succeeds, and you specify the same client token
-- for subsequent successful requests, the IoT Greengrass V2 service
-- returns the successful response that it caches from the previous
-- request. IoT Greengrass V2 caches successful responses for idempotent
-- requests for up to 8 hours.
--
-- 'inlineRecipe', 'createComponentVersion_inlineRecipe' - The recipe to use to create the component. The recipe defines the
-- component\'s metadata, parameters, dependencies, lifecycle, artifacts,
-- and platform compatibility.
--
-- You must specify either @inlineRecipe@ or @lambdaFunction@.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'lambdaFunction', 'createComponentVersion_lambdaFunction' - The parameters to create a component from a Lambda function.
--
-- You must specify either @inlineRecipe@ or @lambdaFunction@.
--
-- 'tags', 'createComponentVersion_tags' - A list of key-value pairs that contain metadata for the resource. For
-- more information, see
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/tag-resources.html Tag your resources>
-- in the /IoT Greengrass V2 Developer Guide/.
newCreateComponentVersion ::
  CreateComponentVersion
newCreateComponentVersion :: CreateComponentVersion
newCreateComponentVersion =
  CreateComponentVersion' :: Maybe Text
-> Maybe Base64
-> Maybe LambdaFunctionRecipeSource
-> Maybe (HashMap Text Text)
-> CreateComponentVersion
CreateComponentVersion'
    { $sel:clientToken:CreateComponentVersion' :: Maybe Text
clientToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:inlineRecipe:CreateComponentVersion' :: Maybe Base64
inlineRecipe = Maybe Base64
forall a. Maybe a
Prelude.Nothing,
      $sel:lambdaFunction:CreateComponentVersion' :: Maybe LambdaFunctionRecipeSource
lambdaFunction = Maybe LambdaFunctionRecipeSource
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateComponentVersion' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | A unique, case-sensitive identifier that you can provide to ensure that
-- the request is idempotent. Idempotency means that the request is
-- successfully processed only once, even if you send the request multiple
-- times. When a request succeeds, and you specify the same client token
-- for subsequent successful requests, the IoT Greengrass V2 service
-- returns the successful response that it caches from the previous
-- request. IoT Greengrass V2 caches successful responses for idempotent
-- requests for up to 8 hours.
createComponentVersion_clientToken :: Lens.Lens' CreateComponentVersion (Prelude.Maybe Prelude.Text)
createComponentVersion_clientToken :: (Maybe Text -> f (Maybe Text))
-> CreateComponentVersion -> f CreateComponentVersion
createComponentVersion_clientToken = (CreateComponentVersion -> Maybe Text)
-> (CreateComponentVersion -> Maybe Text -> CreateComponentVersion)
-> Lens
     CreateComponentVersion
     CreateComponentVersion
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComponentVersion' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateComponentVersion' :: CreateComponentVersion -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateComponentVersion
s@CreateComponentVersion' {} Maybe Text
a -> CreateComponentVersion
s {$sel:clientToken:CreateComponentVersion' :: Maybe Text
clientToken = Maybe Text
a} :: CreateComponentVersion)

-- | The recipe to use to create the component. The recipe defines the
-- component\'s metadata, parameters, dependencies, lifecycle, artifacts,
-- and platform compatibility.
--
-- You must specify either @inlineRecipe@ or @lambdaFunction@.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
createComponentVersion_inlineRecipe :: Lens.Lens' CreateComponentVersion (Prelude.Maybe Prelude.ByteString)
createComponentVersion_inlineRecipe :: (Maybe ByteString -> f (Maybe ByteString))
-> CreateComponentVersion -> f CreateComponentVersion
createComponentVersion_inlineRecipe = (CreateComponentVersion -> Maybe Base64)
-> (CreateComponentVersion
    -> Maybe Base64 -> CreateComponentVersion)
-> Lens
     CreateComponentVersion
     CreateComponentVersion
     (Maybe Base64)
     (Maybe Base64)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComponentVersion' {Maybe Base64
inlineRecipe :: Maybe Base64
$sel:inlineRecipe:CreateComponentVersion' :: CreateComponentVersion -> Maybe Base64
inlineRecipe} -> Maybe Base64
inlineRecipe) (\s :: CreateComponentVersion
s@CreateComponentVersion' {} Maybe Base64
a -> CreateComponentVersion
s {$sel:inlineRecipe:CreateComponentVersion' :: Maybe Base64
inlineRecipe = Maybe Base64
a} :: CreateComponentVersion) ((Maybe Base64 -> f (Maybe Base64))
 -> CreateComponentVersion -> f CreateComponentVersion)
-> ((Maybe ByteString -> f (Maybe ByteString))
    -> Maybe Base64 -> f (Maybe Base64))
-> (Maybe ByteString -> f (Maybe ByteString))
-> CreateComponentVersion
-> f CreateComponentVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso Base64 Base64 ByteString ByteString
-> Iso
     (Maybe Base64) (Maybe Base64) (Maybe ByteString) (Maybe ByteString)
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 Base64 Base64 ByteString ByteString
Iso' Base64 ByteString
Core._Base64

-- | The parameters to create a component from a Lambda function.
--
-- You must specify either @inlineRecipe@ or @lambdaFunction@.
createComponentVersion_lambdaFunction :: Lens.Lens' CreateComponentVersion (Prelude.Maybe LambdaFunctionRecipeSource)
createComponentVersion_lambdaFunction :: (Maybe LambdaFunctionRecipeSource
 -> f (Maybe LambdaFunctionRecipeSource))
-> CreateComponentVersion -> f CreateComponentVersion
createComponentVersion_lambdaFunction = (CreateComponentVersion -> Maybe LambdaFunctionRecipeSource)
-> (CreateComponentVersion
    -> Maybe LambdaFunctionRecipeSource -> CreateComponentVersion)
-> Lens
     CreateComponentVersion
     CreateComponentVersion
     (Maybe LambdaFunctionRecipeSource)
     (Maybe LambdaFunctionRecipeSource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComponentVersion' {Maybe LambdaFunctionRecipeSource
lambdaFunction :: Maybe LambdaFunctionRecipeSource
$sel:lambdaFunction:CreateComponentVersion' :: CreateComponentVersion -> Maybe LambdaFunctionRecipeSource
lambdaFunction} -> Maybe LambdaFunctionRecipeSource
lambdaFunction) (\s :: CreateComponentVersion
s@CreateComponentVersion' {} Maybe LambdaFunctionRecipeSource
a -> CreateComponentVersion
s {$sel:lambdaFunction:CreateComponentVersion' :: Maybe LambdaFunctionRecipeSource
lambdaFunction = Maybe LambdaFunctionRecipeSource
a} :: CreateComponentVersion)

-- | A list of key-value pairs that contain metadata for the resource. For
-- more information, see
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/tag-resources.html Tag your resources>
-- in the /IoT Greengrass V2 Developer Guide/.
createComponentVersion_tags :: Lens.Lens' CreateComponentVersion (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createComponentVersion_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateComponentVersion -> f CreateComponentVersion
createComponentVersion_tags = (CreateComponentVersion -> Maybe (HashMap Text Text))
-> (CreateComponentVersion
    -> Maybe (HashMap Text Text) -> CreateComponentVersion)
-> Lens
     CreateComponentVersion
     CreateComponentVersion
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComponentVersion' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateComponentVersion' :: CreateComponentVersion -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateComponentVersion
s@CreateComponentVersion' {} Maybe (HashMap Text Text)
a -> CreateComponentVersion
s {$sel:tags:CreateComponentVersion' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateComponentVersion) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateComponentVersion -> f CreateComponentVersion)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateComponentVersion
-> f CreateComponentVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateComponentVersion where
  type
    AWSResponse CreateComponentVersion =
      CreateComponentVersionResponse
  request :: CreateComponentVersion -> Request CreateComponentVersion
request = Service -> CreateComponentVersion -> Request CreateComponentVersion
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateComponentVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateComponentVersion)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateComponentVersion))
-> Logger
-> Service
-> Proxy CreateComponentVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateComponentVersion)))
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
-> Text
-> Text
-> POSIX
-> CloudComponentStatus
-> CreateComponentVersionResponse
CreateComponentVersionResponse'
            (Maybe Text
 -> Int
 -> Text
 -> Text
 -> POSIX
 -> CloudComponentStatus
 -> CreateComponentVersionResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Int
      -> Text
      -> Text
      -> POSIX
      -> CloudComponentStatus
      -> CreateComponentVersionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"arn")
            Either
  String
  (Int
   -> Text
   -> Text
   -> POSIX
   -> CloudComponentStatus
   -> CreateComponentVersionResponse)
-> Either String Int
-> Either
     String
     (Text
      -> Text
      -> POSIX
      -> CloudComponentStatus
      -> CreateComponentVersionResponse)
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))
            Either
  String
  (Text
   -> Text
   -> POSIX
   -> CloudComponentStatus
   -> CreateComponentVersionResponse)
-> Either String Text
-> Either
     String
     (Text
      -> POSIX -> CloudComponentStatus -> CreateComponentVersionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"componentName")
            Either
  String
  (Text
   -> POSIX -> CloudComponentStatus -> CreateComponentVersionResponse)
-> Either String Text
-> Either
     String
     (POSIX -> CloudComponentStatus -> CreateComponentVersionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"componentVersion")
            Either
  String
  (POSIX -> CloudComponentStatus -> CreateComponentVersionResponse)
-> Either String POSIX
-> Either
     String (CloudComponentStatus -> CreateComponentVersionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String POSIX
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"creationTimestamp")
            Either
  String (CloudComponentStatus -> CreateComponentVersionResponse)
-> Either String CloudComponentStatus
-> Either String CreateComponentVersionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String CloudComponentStatus
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"status")
      )

instance Prelude.Hashable CreateComponentVersion

instance Prelude.NFData CreateComponentVersion

instance Core.ToHeaders CreateComponentVersion where
  toHeaders :: CreateComponentVersion -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateComponentVersion -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 CreateComponentVersion where
  toJSON :: CreateComponentVersion -> Value
toJSON CreateComponentVersion' {Maybe Text
Maybe (HashMap Text Text)
Maybe Base64
Maybe LambdaFunctionRecipeSource
tags :: Maybe (HashMap Text Text)
lambdaFunction :: Maybe LambdaFunctionRecipeSource
inlineRecipe :: Maybe Base64
clientToken :: Maybe Text
$sel:tags:CreateComponentVersion' :: CreateComponentVersion -> Maybe (HashMap Text Text)
$sel:lambdaFunction:CreateComponentVersion' :: CreateComponentVersion -> Maybe LambdaFunctionRecipeSource
$sel:inlineRecipe:CreateComponentVersion' :: CreateComponentVersion -> Maybe Base64
$sel:clientToken:CreateComponentVersion' :: CreateComponentVersion -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"clientToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
            (Text
"inlineRecipe" Text -> Base64 -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Base64 -> Pair) -> Maybe Base64 -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Base64
inlineRecipe,
            (Text
"lambdaFunction" Text -> LambdaFunctionRecipeSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (LambdaFunctionRecipeSource -> Pair)
-> Maybe LambdaFunctionRecipeSource -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LambdaFunctionRecipeSource
lambdaFunction,
            (Text
"tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags
          ]
      )

instance Core.ToPath CreateComponentVersion where
  toPath :: CreateComponentVersion -> ByteString
toPath =
    ByteString -> CreateComponentVersion -> ByteString
forall a b. a -> b -> a
Prelude.const
      ByteString
"/greengrass/v2/createComponentVersion"

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

-- | /See:/ 'newCreateComponentVersionResponse' smart constructor.
data CreateComponentVersionResponse = CreateComponentVersionResponse'
  { -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
    -- of the component version.
    CreateComponentVersionResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateComponentVersionResponse -> Int
httpStatus :: Prelude.Int,
    -- | The name of the component.
    CreateComponentVersionResponse -> Text
componentName :: Prelude.Text,
    -- | The version of the component.
    CreateComponentVersionResponse -> Text
componentVersion :: Prelude.Text,
    -- | The time at which the component was created, expressed in ISO 8601
    -- format.
    CreateComponentVersionResponse -> POSIX
creationTimestamp :: Core.POSIX,
    -- | The status of the component version in IoT Greengrass V2. This status is
    -- different from the status of the component on a core device.
    CreateComponentVersionResponse -> CloudComponentStatus
status :: CloudComponentStatus
  }
  deriving (CreateComponentVersionResponse
-> CreateComponentVersionResponse -> Bool
(CreateComponentVersionResponse
 -> CreateComponentVersionResponse -> Bool)
-> (CreateComponentVersionResponse
    -> CreateComponentVersionResponse -> Bool)
-> Eq CreateComponentVersionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateComponentVersionResponse
-> CreateComponentVersionResponse -> Bool
$c/= :: CreateComponentVersionResponse
-> CreateComponentVersionResponse -> Bool
== :: CreateComponentVersionResponse
-> CreateComponentVersionResponse -> Bool
$c== :: CreateComponentVersionResponse
-> CreateComponentVersionResponse -> Bool
Prelude.Eq, ReadPrec [CreateComponentVersionResponse]
ReadPrec CreateComponentVersionResponse
Int -> ReadS CreateComponentVersionResponse
ReadS [CreateComponentVersionResponse]
(Int -> ReadS CreateComponentVersionResponse)
-> ReadS [CreateComponentVersionResponse]
-> ReadPrec CreateComponentVersionResponse
-> ReadPrec [CreateComponentVersionResponse]
-> Read CreateComponentVersionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateComponentVersionResponse]
$creadListPrec :: ReadPrec [CreateComponentVersionResponse]
readPrec :: ReadPrec CreateComponentVersionResponse
$creadPrec :: ReadPrec CreateComponentVersionResponse
readList :: ReadS [CreateComponentVersionResponse]
$creadList :: ReadS [CreateComponentVersionResponse]
readsPrec :: Int -> ReadS CreateComponentVersionResponse
$creadsPrec :: Int -> ReadS CreateComponentVersionResponse
Prelude.Read, Int -> CreateComponentVersionResponse -> ShowS
[CreateComponentVersionResponse] -> ShowS
CreateComponentVersionResponse -> String
(Int -> CreateComponentVersionResponse -> ShowS)
-> (CreateComponentVersionResponse -> String)
-> ([CreateComponentVersionResponse] -> ShowS)
-> Show CreateComponentVersionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateComponentVersionResponse] -> ShowS
$cshowList :: [CreateComponentVersionResponse] -> ShowS
show :: CreateComponentVersionResponse -> String
$cshow :: CreateComponentVersionResponse -> String
showsPrec :: Int -> CreateComponentVersionResponse -> ShowS
$cshowsPrec :: Int -> CreateComponentVersionResponse -> ShowS
Prelude.Show, (forall x.
 CreateComponentVersionResponse
 -> Rep CreateComponentVersionResponse x)
-> (forall x.
    Rep CreateComponentVersionResponse x
    -> CreateComponentVersionResponse)
-> Generic CreateComponentVersionResponse
forall x.
Rep CreateComponentVersionResponse x
-> CreateComponentVersionResponse
forall x.
CreateComponentVersionResponse
-> Rep CreateComponentVersionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateComponentVersionResponse x
-> CreateComponentVersionResponse
$cfrom :: forall x.
CreateComponentVersionResponse
-> Rep CreateComponentVersionResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateComponentVersionResponse' 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:
--
-- 'arn', 'createComponentVersionResponse_arn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the component version.
--
-- 'httpStatus', 'createComponentVersionResponse_httpStatus' - The response's http status code.
--
-- 'componentName', 'createComponentVersionResponse_componentName' - The name of the component.
--
-- 'componentVersion', 'createComponentVersionResponse_componentVersion' - The version of the component.
--
-- 'creationTimestamp', 'createComponentVersionResponse_creationTimestamp' - The time at which the component was created, expressed in ISO 8601
-- format.
--
-- 'status', 'createComponentVersionResponse_status' - The status of the component version in IoT Greengrass V2. This status is
-- different from the status of the component on a core device.
newCreateComponentVersionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'componentName'
  Prelude.Text ->
  -- | 'componentVersion'
  Prelude.Text ->
  -- | 'creationTimestamp'
  Prelude.UTCTime ->
  -- | 'status'
  CloudComponentStatus ->
  CreateComponentVersionResponse
newCreateComponentVersionResponse :: Int
-> Text
-> Text
-> UTCTime
-> CloudComponentStatus
-> CreateComponentVersionResponse
newCreateComponentVersionResponse
  Int
pHttpStatus_
  Text
pComponentName_
  Text
pComponentVersion_
  UTCTime
pCreationTimestamp_
  CloudComponentStatus
pStatus_ =
    CreateComponentVersionResponse' :: Maybe Text
-> Int
-> Text
-> Text
-> POSIX
-> CloudComponentStatus
-> CreateComponentVersionResponse
CreateComponentVersionResponse'
      { $sel:arn:CreateComponentVersionResponse' :: Maybe Text
arn =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:CreateComponentVersionResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:componentName:CreateComponentVersionResponse' :: Text
componentName = Text
pComponentName_,
        $sel:componentVersion:CreateComponentVersionResponse' :: Text
componentVersion = Text
pComponentVersion_,
        $sel:creationTimestamp:CreateComponentVersionResponse' :: POSIX
creationTimestamp =
          Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreationTimestamp_,
        $sel:status:CreateComponentVersionResponse' :: CloudComponentStatus
status = CloudComponentStatus
pStatus_
      }

-- | The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the component version.
createComponentVersionResponse_arn :: Lens.Lens' CreateComponentVersionResponse (Prelude.Maybe Prelude.Text)
createComponentVersionResponse_arn :: (Maybe Text -> f (Maybe Text))
-> CreateComponentVersionResponse
-> f CreateComponentVersionResponse
createComponentVersionResponse_arn = (CreateComponentVersionResponse -> Maybe Text)
-> (CreateComponentVersionResponse
    -> Maybe Text -> CreateComponentVersionResponse)
-> Lens
     CreateComponentVersionResponse
     CreateComponentVersionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComponentVersionResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:CreateComponentVersionResponse' :: CreateComponentVersionResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: CreateComponentVersionResponse
s@CreateComponentVersionResponse' {} Maybe Text
a -> CreateComponentVersionResponse
s {$sel:arn:CreateComponentVersionResponse' :: Maybe Text
arn = Maybe Text
a} :: CreateComponentVersionResponse)

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

-- | The name of the component.
createComponentVersionResponse_componentName :: Lens.Lens' CreateComponentVersionResponse Prelude.Text
createComponentVersionResponse_componentName :: (Text -> f Text)
-> CreateComponentVersionResponse
-> f CreateComponentVersionResponse
createComponentVersionResponse_componentName = (CreateComponentVersionResponse -> Text)
-> (CreateComponentVersionResponse
    -> Text -> CreateComponentVersionResponse)
-> Lens
     CreateComponentVersionResponse
     CreateComponentVersionResponse
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComponentVersionResponse' {Text
componentName :: Text
$sel:componentName:CreateComponentVersionResponse' :: CreateComponentVersionResponse -> Text
componentName} -> Text
componentName) (\s :: CreateComponentVersionResponse
s@CreateComponentVersionResponse' {} Text
a -> CreateComponentVersionResponse
s {$sel:componentName:CreateComponentVersionResponse' :: Text
componentName = Text
a} :: CreateComponentVersionResponse)

-- | The version of the component.
createComponentVersionResponse_componentVersion :: Lens.Lens' CreateComponentVersionResponse Prelude.Text
createComponentVersionResponse_componentVersion :: (Text -> f Text)
-> CreateComponentVersionResponse
-> f CreateComponentVersionResponse
createComponentVersionResponse_componentVersion = (CreateComponentVersionResponse -> Text)
-> (CreateComponentVersionResponse
    -> Text -> CreateComponentVersionResponse)
-> Lens
     CreateComponentVersionResponse
     CreateComponentVersionResponse
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComponentVersionResponse' {Text
componentVersion :: Text
$sel:componentVersion:CreateComponentVersionResponse' :: CreateComponentVersionResponse -> Text
componentVersion} -> Text
componentVersion) (\s :: CreateComponentVersionResponse
s@CreateComponentVersionResponse' {} Text
a -> CreateComponentVersionResponse
s {$sel:componentVersion:CreateComponentVersionResponse' :: Text
componentVersion = Text
a} :: CreateComponentVersionResponse)

-- | The time at which the component was created, expressed in ISO 8601
-- format.
createComponentVersionResponse_creationTimestamp :: Lens.Lens' CreateComponentVersionResponse Prelude.UTCTime
createComponentVersionResponse_creationTimestamp :: (UTCTime -> f UTCTime)
-> CreateComponentVersionResponse
-> f CreateComponentVersionResponse
createComponentVersionResponse_creationTimestamp = (CreateComponentVersionResponse -> POSIX)
-> (CreateComponentVersionResponse
    -> POSIX -> CreateComponentVersionResponse)
-> Lens
     CreateComponentVersionResponse
     CreateComponentVersionResponse
     POSIX
     POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComponentVersionResponse' {POSIX
creationTimestamp :: POSIX
$sel:creationTimestamp:CreateComponentVersionResponse' :: CreateComponentVersionResponse -> POSIX
creationTimestamp} -> POSIX
creationTimestamp) (\s :: CreateComponentVersionResponse
s@CreateComponentVersionResponse' {} POSIX
a -> CreateComponentVersionResponse
s {$sel:creationTimestamp:CreateComponentVersionResponse' :: POSIX
creationTimestamp = POSIX
a} :: CreateComponentVersionResponse) ((POSIX -> f POSIX)
 -> CreateComponentVersionResponse
 -> f CreateComponentVersionResponse)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> CreateComponentVersionResponse
-> f CreateComponentVersionResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The status of the component version in IoT Greengrass V2. This status is
-- different from the status of the component on a core device.
createComponentVersionResponse_status :: Lens.Lens' CreateComponentVersionResponse CloudComponentStatus
createComponentVersionResponse_status :: (CloudComponentStatus -> f CloudComponentStatus)
-> CreateComponentVersionResponse
-> f CreateComponentVersionResponse
createComponentVersionResponse_status = (CreateComponentVersionResponse -> CloudComponentStatus)
-> (CreateComponentVersionResponse
    -> CloudComponentStatus -> CreateComponentVersionResponse)
-> Lens
     CreateComponentVersionResponse
     CreateComponentVersionResponse
     CloudComponentStatus
     CloudComponentStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComponentVersionResponse' {CloudComponentStatus
status :: CloudComponentStatus
$sel:status:CreateComponentVersionResponse' :: CreateComponentVersionResponse -> CloudComponentStatus
status} -> CloudComponentStatus
status) (\s :: CreateComponentVersionResponse
s@CreateComponentVersionResponse' {} CloudComponentStatus
a -> CreateComponentVersionResponse
s {$sel:status:CreateComponentVersionResponse' :: CloudComponentStatus
status = CloudComponentStatus
a} :: CreateComponentVersionResponse)

instance
  Prelude.NFData
    CreateComponentVersionResponse