{-# 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.Greengrass.CreateGroupVersion
-- 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 version of a group which has already been defined.
module Amazonka.Greengrass.CreateGroupVersion
  ( -- * Creating a Request
    CreateGroupVersion (..),
    newCreateGroupVersion,

    -- * Request Lenses
    createGroupVersion_amznClientToken,
    createGroupVersion_resourceDefinitionVersionArn,
    createGroupVersion_subscriptionDefinitionVersionArn,
    createGroupVersion_coreDefinitionVersionArn,
    createGroupVersion_deviceDefinitionVersionArn,
    createGroupVersion_functionDefinitionVersionArn,
    createGroupVersion_loggerDefinitionVersionArn,
    createGroupVersion_connectorDefinitionVersionArn,
    createGroupVersion_groupId,

    -- * Destructuring the Response
    CreateGroupVersionResponse (..),
    newCreateGroupVersionResponse,

    -- * Response Lenses
    createGroupVersionResponse_arn,
    createGroupVersionResponse_creationTimestamp,
    createGroupVersionResponse_version,
    createGroupVersionResponse_id,
    createGroupVersionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Greengrass.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:/ 'newCreateGroupVersion' smart constructor.
data CreateGroupVersion = CreateGroupVersion'
  { -- | A client token used to correlate requests and responses.
    CreateGroupVersion -> Maybe Text
amznClientToken :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the resource definition version for this group.
    CreateGroupVersion -> Maybe Text
resourceDefinitionVersionArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the subscription definition version for this group.
    CreateGroupVersion -> Maybe Text
subscriptionDefinitionVersionArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the core definition version for this group.
    CreateGroupVersion -> Maybe Text
coreDefinitionVersionArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the device definition version for this group.
    CreateGroupVersion -> Maybe Text
deviceDefinitionVersionArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the function definition version for this group.
    CreateGroupVersion -> Maybe Text
functionDefinitionVersionArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the logger definition version for this group.
    CreateGroupVersion -> Maybe Text
loggerDefinitionVersionArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the connector definition version for this group.
    CreateGroupVersion -> Maybe Text
connectorDefinitionVersionArn :: Prelude.Maybe Prelude.Text,
    -- | The ID of the Greengrass group.
    CreateGroupVersion -> Text
groupId :: Prelude.Text
  }
  deriving (CreateGroupVersion -> CreateGroupVersion -> Bool
(CreateGroupVersion -> CreateGroupVersion -> Bool)
-> (CreateGroupVersion -> CreateGroupVersion -> Bool)
-> Eq CreateGroupVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGroupVersion -> CreateGroupVersion -> Bool
$c/= :: CreateGroupVersion -> CreateGroupVersion -> Bool
== :: CreateGroupVersion -> CreateGroupVersion -> Bool
$c== :: CreateGroupVersion -> CreateGroupVersion -> Bool
Prelude.Eq, ReadPrec [CreateGroupVersion]
ReadPrec CreateGroupVersion
Int -> ReadS CreateGroupVersion
ReadS [CreateGroupVersion]
(Int -> ReadS CreateGroupVersion)
-> ReadS [CreateGroupVersion]
-> ReadPrec CreateGroupVersion
-> ReadPrec [CreateGroupVersion]
-> Read CreateGroupVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateGroupVersion]
$creadListPrec :: ReadPrec [CreateGroupVersion]
readPrec :: ReadPrec CreateGroupVersion
$creadPrec :: ReadPrec CreateGroupVersion
readList :: ReadS [CreateGroupVersion]
$creadList :: ReadS [CreateGroupVersion]
readsPrec :: Int -> ReadS CreateGroupVersion
$creadsPrec :: Int -> ReadS CreateGroupVersion
Prelude.Read, Int -> CreateGroupVersion -> ShowS
[CreateGroupVersion] -> ShowS
CreateGroupVersion -> String
(Int -> CreateGroupVersion -> ShowS)
-> (CreateGroupVersion -> String)
-> ([CreateGroupVersion] -> ShowS)
-> Show CreateGroupVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGroupVersion] -> ShowS
$cshowList :: [CreateGroupVersion] -> ShowS
show :: CreateGroupVersion -> String
$cshow :: CreateGroupVersion -> String
showsPrec :: Int -> CreateGroupVersion -> ShowS
$cshowsPrec :: Int -> CreateGroupVersion -> ShowS
Prelude.Show, (forall x. CreateGroupVersion -> Rep CreateGroupVersion x)
-> (forall x. Rep CreateGroupVersion x -> CreateGroupVersion)
-> Generic CreateGroupVersion
forall x. Rep CreateGroupVersion x -> CreateGroupVersion
forall x. CreateGroupVersion -> Rep CreateGroupVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateGroupVersion x -> CreateGroupVersion
$cfrom :: forall x. CreateGroupVersion -> Rep CreateGroupVersion x
Prelude.Generic)

-- |
-- Create a value of 'CreateGroupVersion' 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:
--
-- 'amznClientToken', 'createGroupVersion_amznClientToken' - A client token used to correlate requests and responses.
--
-- 'resourceDefinitionVersionArn', 'createGroupVersion_resourceDefinitionVersionArn' - The ARN of the resource definition version for this group.
--
-- 'subscriptionDefinitionVersionArn', 'createGroupVersion_subscriptionDefinitionVersionArn' - The ARN of the subscription definition version for this group.
--
-- 'coreDefinitionVersionArn', 'createGroupVersion_coreDefinitionVersionArn' - The ARN of the core definition version for this group.
--
-- 'deviceDefinitionVersionArn', 'createGroupVersion_deviceDefinitionVersionArn' - The ARN of the device definition version for this group.
--
-- 'functionDefinitionVersionArn', 'createGroupVersion_functionDefinitionVersionArn' - The ARN of the function definition version for this group.
--
-- 'loggerDefinitionVersionArn', 'createGroupVersion_loggerDefinitionVersionArn' - The ARN of the logger definition version for this group.
--
-- 'connectorDefinitionVersionArn', 'createGroupVersion_connectorDefinitionVersionArn' - The ARN of the connector definition version for this group.
--
-- 'groupId', 'createGroupVersion_groupId' - The ID of the Greengrass group.
newCreateGroupVersion ::
  -- | 'groupId'
  Prelude.Text ->
  CreateGroupVersion
newCreateGroupVersion :: Text -> CreateGroupVersion
newCreateGroupVersion Text
pGroupId_ =
  CreateGroupVersion' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> CreateGroupVersion
CreateGroupVersion'
    { $sel:amznClientToken:CreateGroupVersion' :: Maybe Text
amznClientToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
resourceDefinitionVersionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subscriptionDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
subscriptionDefinitionVersionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:coreDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
coreDefinitionVersionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
deviceDefinitionVersionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:functionDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
functionDefinitionVersionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:loggerDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
loggerDefinitionVersionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectorDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
connectorDefinitionVersionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groupId:CreateGroupVersion' :: Text
groupId = Text
pGroupId_
    }

-- | A client token used to correlate requests and responses.
createGroupVersion_amznClientToken :: Lens.Lens' CreateGroupVersion (Prelude.Maybe Prelude.Text)
createGroupVersion_amznClientToken :: (Maybe Text -> f (Maybe Text))
-> CreateGroupVersion -> f CreateGroupVersion
createGroupVersion_amznClientToken = (CreateGroupVersion -> Maybe Text)
-> (CreateGroupVersion -> Maybe Text -> CreateGroupVersion)
-> Lens
     CreateGroupVersion CreateGroupVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroupVersion' {Maybe Text
amznClientToken :: Maybe Text
$sel:amznClientToken:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
amznClientToken} -> Maybe Text
amznClientToken) (\s :: CreateGroupVersion
s@CreateGroupVersion' {} Maybe Text
a -> CreateGroupVersion
s {$sel:amznClientToken:CreateGroupVersion' :: Maybe Text
amznClientToken = Maybe Text
a} :: CreateGroupVersion)

-- | The ARN of the resource definition version for this group.
createGroupVersion_resourceDefinitionVersionArn :: Lens.Lens' CreateGroupVersion (Prelude.Maybe Prelude.Text)
createGroupVersion_resourceDefinitionVersionArn :: (Maybe Text -> f (Maybe Text))
-> CreateGroupVersion -> f CreateGroupVersion
createGroupVersion_resourceDefinitionVersionArn = (CreateGroupVersion -> Maybe Text)
-> (CreateGroupVersion -> Maybe Text -> CreateGroupVersion)
-> Lens
     CreateGroupVersion CreateGroupVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroupVersion' {Maybe Text
resourceDefinitionVersionArn :: Maybe Text
$sel:resourceDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
resourceDefinitionVersionArn} -> Maybe Text
resourceDefinitionVersionArn) (\s :: CreateGroupVersion
s@CreateGroupVersion' {} Maybe Text
a -> CreateGroupVersion
s {$sel:resourceDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
resourceDefinitionVersionArn = Maybe Text
a} :: CreateGroupVersion)

-- | The ARN of the subscription definition version for this group.
createGroupVersion_subscriptionDefinitionVersionArn :: Lens.Lens' CreateGroupVersion (Prelude.Maybe Prelude.Text)
createGroupVersion_subscriptionDefinitionVersionArn :: (Maybe Text -> f (Maybe Text))
-> CreateGroupVersion -> f CreateGroupVersion
createGroupVersion_subscriptionDefinitionVersionArn = (CreateGroupVersion -> Maybe Text)
-> (CreateGroupVersion -> Maybe Text -> CreateGroupVersion)
-> Lens
     CreateGroupVersion CreateGroupVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroupVersion' {Maybe Text
subscriptionDefinitionVersionArn :: Maybe Text
$sel:subscriptionDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
subscriptionDefinitionVersionArn} -> Maybe Text
subscriptionDefinitionVersionArn) (\s :: CreateGroupVersion
s@CreateGroupVersion' {} Maybe Text
a -> CreateGroupVersion
s {$sel:subscriptionDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
subscriptionDefinitionVersionArn = Maybe Text
a} :: CreateGroupVersion)

-- | The ARN of the core definition version for this group.
createGroupVersion_coreDefinitionVersionArn :: Lens.Lens' CreateGroupVersion (Prelude.Maybe Prelude.Text)
createGroupVersion_coreDefinitionVersionArn :: (Maybe Text -> f (Maybe Text))
-> CreateGroupVersion -> f CreateGroupVersion
createGroupVersion_coreDefinitionVersionArn = (CreateGroupVersion -> Maybe Text)
-> (CreateGroupVersion -> Maybe Text -> CreateGroupVersion)
-> Lens
     CreateGroupVersion CreateGroupVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroupVersion' {Maybe Text
coreDefinitionVersionArn :: Maybe Text
$sel:coreDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
coreDefinitionVersionArn} -> Maybe Text
coreDefinitionVersionArn) (\s :: CreateGroupVersion
s@CreateGroupVersion' {} Maybe Text
a -> CreateGroupVersion
s {$sel:coreDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
coreDefinitionVersionArn = Maybe Text
a} :: CreateGroupVersion)

-- | The ARN of the device definition version for this group.
createGroupVersion_deviceDefinitionVersionArn :: Lens.Lens' CreateGroupVersion (Prelude.Maybe Prelude.Text)
createGroupVersion_deviceDefinitionVersionArn :: (Maybe Text -> f (Maybe Text))
-> CreateGroupVersion -> f CreateGroupVersion
createGroupVersion_deviceDefinitionVersionArn = (CreateGroupVersion -> Maybe Text)
-> (CreateGroupVersion -> Maybe Text -> CreateGroupVersion)
-> Lens
     CreateGroupVersion CreateGroupVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroupVersion' {Maybe Text
deviceDefinitionVersionArn :: Maybe Text
$sel:deviceDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
deviceDefinitionVersionArn} -> Maybe Text
deviceDefinitionVersionArn) (\s :: CreateGroupVersion
s@CreateGroupVersion' {} Maybe Text
a -> CreateGroupVersion
s {$sel:deviceDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
deviceDefinitionVersionArn = Maybe Text
a} :: CreateGroupVersion)

-- | The ARN of the function definition version for this group.
createGroupVersion_functionDefinitionVersionArn :: Lens.Lens' CreateGroupVersion (Prelude.Maybe Prelude.Text)
createGroupVersion_functionDefinitionVersionArn :: (Maybe Text -> f (Maybe Text))
-> CreateGroupVersion -> f CreateGroupVersion
createGroupVersion_functionDefinitionVersionArn = (CreateGroupVersion -> Maybe Text)
-> (CreateGroupVersion -> Maybe Text -> CreateGroupVersion)
-> Lens
     CreateGroupVersion CreateGroupVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroupVersion' {Maybe Text
functionDefinitionVersionArn :: Maybe Text
$sel:functionDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
functionDefinitionVersionArn} -> Maybe Text
functionDefinitionVersionArn) (\s :: CreateGroupVersion
s@CreateGroupVersion' {} Maybe Text
a -> CreateGroupVersion
s {$sel:functionDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
functionDefinitionVersionArn = Maybe Text
a} :: CreateGroupVersion)

-- | The ARN of the logger definition version for this group.
createGroupVersion_loggerDefinitionVersionArn :: Lens.Lens' CreateGroupVersion (Prelude.Maybe Prelude.Text)
createGroupVersion_loggerDefinitionVersionArn :: (Maybe Text -> f (Maybe Text))
-> CreateGroupVersion -> f CreateGroupVersion
createGroupVersion_loggerDefinitionVersionArn = (CreateGroupVersion -> Maybe Text)
-> (CreateGroupVersion -> Maybe Text -> CreateGroupVersion)
-> Lens
     CreateGroupVersion CreateGroupVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroupVersion' {Maybe Text
loggerDefinitionVersionArn :: Maybe Text
$sel:loggerDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
loggerDefinitionVersionArn} -> Maybe Text
loggerDefinitionVersionArn) (\s :: CreateGroupVersion
s@CreateGroupVersion' {} Maybe Text
a -> CreateGroupVersion
s {$sel:loggerDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
loggerDefinitionVersionArn = Maybe Text
a} :: CreateGroupVersion)

-- | The ARN of the connector definition version for this group.
createGroupVersion_connectorDefinitionVersionArn :: Lens.Lens' CreateGroupVersion (Prelude.Maybe Prelude.Text)
createGroupVersion_connectorDefinitionVersionArn :: (Maybe Text -> f (Maybe Text))
-> CreateGroupVersion -> f CreateGroupVersion
createGroupVersion_connectorDefinitionVersionArn = (CreateGroupVersion -> Maybe Text)
-> (CreateGroupVersion -> Maybe Text -> CreateGroupVersion)
-> Lens
     CreateGroupVersion CreateGroupVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroupVersion' {Maybe Text
connectorDefinitionVersionArn :: Maybe Text
$sel:connectorDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
connectorDefinitionVersionArn} -> Maybe Text
connectorDefinitionVersionArn) (\s :: CreateGroupVersion
s@CreateGroupVersion' {} Maybe Text
a -> CreateGroupVersion
s {$sel:connectorDefinitionVersionArn:CreateGroupVersion' :: Maybe Text
connectorDefinitionVersionArn = Maybe Text
a} :: CreateGroupVersion)

-- | The ID of the Greengrass group.
createGroupVersion_groupId :: Lens.Lens' CreateGroupVersion Prelude.Text
createGroupVersion_groupId :: (Text -> f Text) -> CreateGroupVersion -> f CreateGroupVersion
createGroupVersion_groupId = (CreateGroupVersion -> Text)
-> (CreateGroupVersion -> Text -> CreateGroupVersion)
-> Lens CreateGroupVersion CreateGroupVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroupVersion' {Text
groupId :: Text
$sel:groupId:CreateGroupVersion' :: CreateGroupVersion -> Text
groupId} -> Text
groupId) (\s :: CreateGroupVersion
s@CreateGroupVersion' {} Text
a -> CreateGroupVersion
s {$sel:groupId:CreateGroupVersion' :: Text
groupId = Text
a} :: CreateGroupVersion)

instance Core.AWSRequest CreateGroupVersion where
  type
    AWSResponse CreateGroupVersion =
      CreateGroupVersionResponse
  request :: CreateGroupVersion -> Request CreateGroupVersion
request = Service -> CreateGroupVersion -> Request CreateGroupVersion
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateGroupVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateGroupVersion)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateGroupVersion))
-> Logger
-> Service
-> Proxy CreateGroupVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateGroupVersion)))
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
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> CreateGroupVersionResponse
CreateGroupVersionResponse'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Int
 -> CreateGroupVersionResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Int -> CreateGroupVersionResponse)
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
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Int -> CreateGroupVersionResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text -> Maybe Text -> Int -> CreateGroupVersionResponse)
forall (f :: * -> *) a b. Applicative f => 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
"CreationTimestamp")
            Either
  String
  (Maybe Text -> Maybe Text -> Int -> CreateGroupVersionResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CreateGroupVersionResponse)
forall (f :: * -> *) a b. Applicative f => 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
"Version")
            Either String (Maybe Text -> Int -> CreateGroupVersionResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateGroupVersionResponse)
forall (f :: * -> *) a b. Applicative f => 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
"Id")
            Either String (Int -> CreateGroupVersionResponse)
-> Either String Int -> Either String CreateGroupVersionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateGroupVersion

instance Prelude.NFData CreateGroupVersion

instance Core.ToHeaders CreateGroupVersion where
  toHeaders :: CreateGroupVersion -> ResponseHeaders
toHeaders CreateGroupVersion' {Maybe Text
Text
groupId :: Text
connectorDefinitionVersionArn :: Maybe Text
loggerDefinitionVersionArn :: Maybe Text
functionDefinitionVersionArn :: Maybe Text
deviceDefinitionVersionArn :: Maybe Text
coreDefinitionVersionArn :: Maybe Text
subscriptionDefinitionVersionArn :: Maybe Text
resourceDefinitionVersionArn :: Maybe Text
amznClientToken :: Maybe Text
$sel:groupId:CreateGroupVersion' :: CreateGroupVersion -> Text
$sel:connectorDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:loggerDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:functionDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:deviceDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:coreDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:subscriptionDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:resourceDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:amznClientToken:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"X-Amzn-Client-Token" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
amznClientToken,
        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 CreateGroupVersion where
  toJSON :: CreateGroupVersion -> Value
toJSON CreateGroupVersion' {Maybe Text
Text
groupId :: Text
connectorDefinitionVersionArn :: Maybe Text
loggerDefinitionVersionArn :: Maybe Text
functionDefinitionVersionArn :: Maybe Text
deviceDefinitionVersionArn :: Maybe Text
coreDefinitionVersionArn :: Maybe Text
subscriptionDefinitionVersionArn :: Maybe Text
resourceDefinitionVersionArn :: Maybe Text
amznClientToken :: Maybe Text
$sel:groupId:CreateGroupVersion' :: CreateGroupVersion -> Text
$sel:connectorDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:loggerDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:functionDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:deviceDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:coreDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:subscriptionDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:resourceDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:amznClientToken:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ResourceDefinitionVersionArn" 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
resourceDefinitionVersionArn,
            (Text
"SubscriptionDefinitionVersionArn" 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
subscriptionDefinitionVersionArn,
            (Text
"CoreDefinitionVersionArn" 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
coreDefinitionVersionArn,
            (Text
"DeviceDefinitionVersionArn" 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
deviceDefinitionVersionArn,
            (Text
"FunctionDefinitionVersionArn" 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
functionDefinitionVersionArn,
            (Text
"LoggerDefinitionVersionArn" 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
loggerDefinitionVersionArn,
            (Text
"ConnectorDefinitionVersionArn" 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
connectorDefinitionVersionArn
          ]
      )

instance Core.ToPath CreateGroupVersion where
  toPath :: CreateGroupVersion -> ByteString
toPath CreateGroupVersion' {Maybe Text
Text
groupId :: Text
connectorDefinitionVersionArn :: Maybe Text
loggerDefinitionVersionArn :: Maybe Text
functionDefinitionVersionArn :: Maybe Text
deviceDefinitionVersionArn :: Maybe Text
coreDefinitionVersionArn :: Maybe Text
subscriptionDefinitionVersionArn :: Maybe Text
resourceDefinitionVersionArn :: Maybe Text
amznClientToken :: Maybe Text
$sel:groupId:CreateGroupVersion' :: CreateGroupVersion -> Text
$sel:connectorDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:loggerDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:functionDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:deviceDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:coreDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:subscriptionDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:resourceDefinitionVersionArn:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
$sel:amznClientToken:CreateGroupVersion' :: CreateGroupVersion -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/greengrass/groups/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
groupId,
        ByteString
"/versions"
      ]

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

-- | /See:/ 'newCreateGroupVersionResponse' smart constructor.
data CreateGroupVersionResponse = CreateGroupVersionResponse'
  { -- | The ARN of the version.
    CreateGroupVersionResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The time, in milliseconds since the epoch, when the version was created.
    CreateGroupVersionResponse -> Maybe Text
creationTimestamp :: Prelude.Maybe Prelude.Text,
    -- | The ID of the version.
    CreateGroupVersionResponse -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | The ID of the parent definition that the version is associated with.
    CreateGroupVersionResponse -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateGroupVersionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateGroupVersionResponse -> CreateGroupVersionResponse -> Bool
(CreateGroupVersionResponse -> CreateGroupVersionResponse -> Bool)
-> (CreateGroupVersionResponse
    -> CreateGroupVersionResponse -> Bool)
-> Eq CreateGroupVersionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGroupVersionResponse -> CreateGroupVersionResponse -> Bool
$c/= :: CreateGroupVersionResponse -> CreateGroupVersionResponse -> Bool
== :: CreateGroupVersionResponse -> CreateGroupVersionResponse -> Bool
$c== :: CreateGroupVersionResponse -> CreateGroupVersionResponse -> Bool
Prelude.Eq, ReadPrec [CreateGroupVersionResponse]
ReadPrec CreateGroupVersionResponse
Int -> ReadS CreateGroupVersionResponse
ReadS [CreateGroupVersionResponse]
(Int -> ReadS CreateGroupVersionResponse)
-> ReadS [CreateGroupVersionResponse]
-> ReadPrec CreateGroupVersionResponse
-> ReadPrec [CreateGroupVersionResponse]
-> Read CreateGroupVersionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateGroupVersionResponse]
$creadListPrec :: ReadPrec [CreateGroupVersionResponse]
readPrec :: ReadPrec CreateGroupVersionResponse
$creadPrec :: ReadPrec CreateGroupVersionResponse
readList :: ReadS [CreateGroupVersionResponse]
$creadList :: ReadS [CreateGroupVersionResponse]
readsPrec :: Int -> ReadS CreateGroupVersionResponse
$creadsPrec :: Int -> ReadS CreateGroupVersionResponse
Prelude.Read, Int -> CreateGroupVersionResponse -> ShowS
[CreateGroupVersionResponse] -> ShowS
CreateGroupVersionResponse -> String
(Int -> CreateGroupVersionResponse -> ShowS)
-> (CreateGroupVersionResponse -> String)
-> ([CreateGroupVersionResponse] -> ShowS)
-> Show CreateGroupVersionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGroupVersionResponse] -> ShowS
$cshowList :: [CreateGroupVersionResponse] -> ShowS
show :: CreateGroupVersionResponse -> String
$cshow :: CreateGroupVersionResponse -> String
showsPrec :: Int -> CreateGroupVersionResponse -> ShowS
$cshowsPrec :: Int -> CreateGroupVersionResponse -> ShowS
Prelude.Show, (forall x.
 CreateGroupVersionResponse -> Rep CreateGroupVersionResponse x)
-> (forall x.
    Rep CreateGroupVersionResponse x -> CreateGroupVersionResponse)
-> Generic CreateGroupVersionResponse
forall x.
Rep CreateGroupVersionResponse x -> CreateGroupVersionResponse
forall x.
CreateGroupVersionResponse -> Rep CreateGroupVersionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateGroupVersionResponse x -> CreateGroupVersionResponse
$cfrom :: forall x.
CreateGroupVersionResponse -> Rep CreateGroupVersionResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateGroupVersionResponse' 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', 'createGroupVersionResponse_arn' - The ARN of the version.
--
-- 'creationTimestamp', 'createGroupVersionResponse_creationTimestamp' - The time, in milliseconds since the epoch, when the version was created.
--
-- 'version', 'createGroupVersionResponse_version' - The ID of the version.
--
-- 'id', 'createGroupVersionResponse_id' - The ID of the parent definition that the version is associated with.
--
-- 'httpStatus', 'createGroupVersionResponse_httpStatus' - The response's http status code.
newCreateGroupVersionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateGroupVersionResponse
newCreateGroupVersionResponse :: Int -> CreateGroupVersionResponse
newCreateGroupVersionResponse Int
pHttpStatus_ =
  CreateGroupVersionResponse' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> CreateGroupVersionResponse
CreateGroupVersionResponse'
    { $sel:arn:CreateGroupVersionResponse' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTimestamp:CreateGroupVersionResponse' :: Maybe Text
creationTimestamp = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:version:CreateGroupVersionResponse' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:CreateGroupVersionResponse' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateGroupVersionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the version.
createGroupVersionResponse_arn :: Lens.Lens' CreateGroupVersionResponse (Prelude.Maybe Prelude.Text)
createGroupVersionResponse_arn :: (Maybe Text -> f (Maybe Text))
-> CreateGroupVersionResponse -> f CreateGroupVersionResponse
createGroupVersionResponse_arn = (CreateGroupVersionResponse -> Maybe Text)
-> (CreateGroupVersionResponse
    -> Maybe Text -> CreateGroupVersionResponse)
-> Lens
     CreateGroupVersionResponse
     CreateGroupVersionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroupVersionResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:CreateGroupVersionResponse' :: CreateGroupVersionResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: CreateGroupVersionResponse
s@CreateGroupVersionResponse' {} Maybe Text
a -> CreateGroupVersionResponse
s {$sel:arn:CreateGroupVersionResponse' :: Maybe Text
arn = Maybe Text
a} :: CreateGroupVersionResponse)

-- | The time, in milliseconds since the epoch, when the version was created.
createGroupVersionResponse_creationTimestamp :: Lens.Lens' CreateGroupVersionResponse (Prelude.Maybe Prelude.Text)
createGroupVersionResponse_creationTimestamp :: (Maybe Text -> f (Maybe Text))
-> CreateGroupVersionResponse -> f CreateGroupVersionResponse
createGroupVersionResponse_creationTimestamp = (CreateGroupVersionResponse -> Maybe Text)
-> (CreateGroupVersionResponse
    -> Maybe Text -> CreateGroupVersionResponse)
-> Lens
     CreateGroupVersionResponse
     CreateGroupVersionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroupVersionResponse' {Maybe Text
creationTimestamp :: Maybe Text
$sel:creationTimestamp:CreateGroupVersionResponse' :: CreateGroupVersionResponse -> Maybe Text
creationTimestamp} -> Maybe Text
creationTimestamp) (\s :: CreateGroupVersionResponse
s@CreateGroupVersionResponse' {} Maybe Text
a -> CreateGroupVersionResponse
s {$sel:creationTimestamp:CreateGroupVersionResponse' :: Maybe Text
creationTimestamp = Maybe Text
a} :: CreateGroupVersionResponse)

-- | The ID of the version.
createGroupVersionResponse_version :: Lens.Lens' CreateGroupVersionResponse (Prelude.Maybe Prelude.Text)
createGroupVersionResponse_version :: (Maybe Text -> f (Maybe Text))
-> CreateGroupVersionResponse -> f CreateGroupVersionResponse
createGroupVersionResponse_version = (CreateGroupVersionResponse -> Maybe Text)
-> (CreateGroupVersionResponse
    -> Maybe Text -> CreateGroupVersionResponse)
-> Lens
     CreateGroupVersionResponse
     CreateGroupVersionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroupVersionResponse' {Maybe Text
version :: Maybe Text
$sel:version:CreateGroupVersionResponse' :: CreateGroupVersionResponse -> Maybe Text
version} -> Maybe Text
version) (\s :: CreateGroupVersionResponse
s@CreateGroupVersionResponse' {} Maybe Text
a -> CreateGroupVersionResponse
s {$sel:version:CreateGroupVersionResponse' :: Maybe Text
version = Maybe Text
a} :: CreateGroupVersionResponse)

-- | The ID of the parent definition that the version is associated with.
createGroupVersionResponse_id :: Lens.Lens' CreateGroupVersionResponse (Prelude.Maybe Prelude.Text)
createGroupVersionResponse_id :: (Maybe Text -> f (Maybe Text))
-> CreateGroupVersionResponse -> f CreateGroupVersionResponse
createGroupVersionResponse_id = (CreateGroupVersionResponse -> Maybe Text)
-> (CreateGroupVersionResponse
    -> Maybe Text -> CreateGroupVersionResponse)
-> Lens
     CreateGroupVersionResponse
     CreateGroupVersionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroupVersionResponse' {Maybe Text
id :: Maybe Text
$sel:id:CreateGroupVersionResponse' :: CreateGroupVersionResponse -> Maybe Text
id} -> Maybe Text
id) (\s :: CreateGroupVersionResponse
s@CreateGroupVersionResponse' {} Maybe Text
a -> CreateGroupVersionResponse
s {$sel:id:CreateGroupVersionResponse' :: Maybe Text
id = Maybe Text
a} :: CreateGroupVersionResponse)

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

instance Prelude.NFData CreateGroupVersionResponse