{-# 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.SSM.CreateActivation
-- 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)
--
-- Generates an activation code and activation ID you can use to register
-- your on-premises server or virtual machine (VM) with Amazon Web Services
-- Systems Manager. Registering these machines with Systems Manager makes
-- it possible to manage them using Systems Manager capabilities. You use
-- the activation code and ID when installing SSM Agent on machines in your
-- hybrid environment. For more information about requirements for managing
-- on-premises instances and VMs using Systems Manager, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-managedinstances.html Setting up Amazon Web Services Systems Manager for hybrid environments>
-- in the /Amazon Web Services Systems Manager User Guide/.
--
-- On-premises servers or VMs that are registered with Systems Manager and
-- Amazon Elastic Compute Cloud (Amazon EC2) instances that you manage with
-- Systems Manager are all called /managed instances/.
module Amazonka.SSM.CreateActivation
  ( -- * Creating a Request
    CreateActivation (..),
    newCreateActivation,

    -- * Request Lenses
    createActivation_defaultInstanceName,
    createActivation_registrationLimit,
    createActivation_expirationDate,
    createActivation_description,
    createActivation_tags,
    createActivation_iamRole,

    -- * Destructuring the Response
    CreateActivationResponse (..),
    newCreateActivationResponse,

    -- * Response Lenses
    createActivationResponse_activationId,
    createActivationResponse_activationCode,
    createActivationResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SSM.Types

-- | /See:/ 'newCreateActivation' smart constructor.
data CreateActivation = CreateActivation'
  { -- | The name of the registered, managed instance as it will appear in the
    -- Amazon Web Services Systems Manager console or when you use the Amazon
    -- Web Services command line tools to list Systems Manager resources.
    --
    -- Don\'t enter personally identifiable information in this field.
    CreateActivation -> Maybe Text
defaultInstanceName :: Prelude.Maybe Prelude.Text,
    -- | Specify the maximum number of managed instances you want to register.
    -- The default value is @1@.
    CreateActivation -> Maybe Natural
registrationLimit :: Prelude.Maybe Prelude.Natural,
    -- | The date by which this activation request should expire, in timestamp
    -- format, such as \"2021-07-07T00:00:00\". You can specify a date up to 30
    -- days in advance. If you don\'t provide an expiration date, the
    -- activation code expires in 24 hours.
    CreateActivation -> Maybe POSIX
expirationDate :: Prelude.Maybe Core.POSIX,
    -- | A user-defined description of the resource that you want to register
    -- with Systems Manager.
    --
    -- Don\'t enter personally identifiable information in this field.
    CreateActivation -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Optional metadata that you assign to a resource. Tags enable you to
    -- categorize a resource in different ways, such as by purpose, owner, or
    -- environment. For example, you might want to tag an activation to
    -- identify which servers or virtual machines (VMs) in your on-premises
    -- environment you intend to activate. In this case, you could specify the
    -- following key-value pairs:
    --
    -- -   @Key=OS,Value=Windows@
    --
    -- -   @Key=Environment,Value=Production@
    --
    -- When you install SSM Agent on your on-premises servers and VMs, you
    -- specify an activation ID and code. When you specify the activation ID
    -- and code, tags assigned to the activation are automatically applied to
    -- the on-premises servers or VMs.
    --
    -- You can\'t add tags to or delete tags from an existing activation. You
    -- can tag your on-premises servers and VMs after they connect to Systems
    -- Manager for the first time and are assigned a managed instance ID. This
    -- means they are listed in the Amazon Web Services Systems Manager console
    -- with an ID that is prefixed with \"mi-\". For information about how to
    -- add tags to your managed instances, see AddTagsToResource. For
    -- information about how to remove tags from your managed instances, see
    -- RemoveTagsFromResource.
    CreateActivation -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name of the Identity and Access Management (IAM) role that you want
    -- to assign to the managed instance. This IAM role must provide AssumeRole
    -- permissions for the Amazon Web Services Systems Manager service
    -- principal @ssm.amazonaws.com@. For more information, see
    -- <https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-service-role.html Create an IAM service role for a hybrid environment>
    -- in the /Amazon Web Services Systems Manager User Guide/.
    CreateActivation -> Text
iamRole :: Prelude.Text
  }
  deriving (CreateActivation -> CreateActivation -> Bool
(CreateActivation -> CreateActivation -> Bool)
-> (CreateActivation -> CreateActivation -> Bool)
-> Eq CreateActivation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateActivation -> CreateActivation -> Bool
$c/= :: CreateActivation -> CreateActivation -> Bool
== :: CreateActivation -> CreateActivation -> Bool
$c== :: CreateActivation -> CreateActivation -> Bool
Prelude.Eq, ReadPrec [CreateActivation]
ReadPrec CreateActivation
Int -> ReadS CreateActivation
ReadS [CreateActivation]
(Int -> ReadS CreateActivation)
-> ReadS [CreateActivation]
-> ReadPrec CreateActivation
-> ReadPrec [CreateActivation]
-> Read CreateActivation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateActivation]
$creadListPrec :: ReadPrec [CreateActivation]
readPrec :: ReadPrec CreateActivation
$creadPrec :: ReadPrec CreateActivation
readList :: ReadS [CreateActivation]
$creadList :: ReadS [CreateActivation]
readsPrec :: Int -> ReadS CreateActivation
$creadsPrec :: Int -> ReadS CreateActivation
Prelude.Read, Int -> CreateActivation -> ShowS
[CreateActivation] -> ShowS
CreateActivation -> String
(Int -> CreateActivation -> ShowS)
-> (CreateActivation -> String)
-> ([CreateActivation] -> ShowS)
-> Show CreateActivation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateActivation] -> ShowS
$cshowList :: [CreateActivation] -> ShowS
show :: CreateActivation -> String
$cshow :: CreateActivation -> String
showsPrec :: Int -> CreateActivation -> ShowS
$cshowsPrec :: Int -> CreateActivation -> ShowS
Prelude.Show, (forall x. CreateActivation -> Rep CreateActivation x)
-> (forall x. Rep CreateActivation x -> CreateActivation)
-> Generic CreateActivation
forall x. Rep CreateActivation x -> CreateActivation
forall x. CreateActivation -> Rep CreateActivation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateActivation x -> CreateActivation
$cfrom :: forall x. CreateActivation -> Rep CreateActivation x
Prelude.Generic)

-- |
-- Create a value of 'CreateActivation' 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:
--
-- 'defaultInstanceName', 'createActivation_defaultInstanceName' - The name of the registered, managed instance as it will appear in the
-- Amazon Web Services Systems Manager console or when you use the Amazon
-- Web Services command line tools to list Systems Manager resources.
--
-- Don\'t enter personally identifiable information in this field.
--
-- 'registrationLimit', 'createActivation_registrationLimit' - Specify the maximum number of managed instances you want to register.
-- The default value is @1@.
--
-- 'expirationDate', 'createActivation_expirationDate' - The date by which this activation request should expire, in timestamp
-- format, such as \"2021-07-07T00:00:00\". You can specify a date up to 30
-- days in advance. If you don\'t provide an expiration date, the
-- activation code expires in 24 hours.
--
-- 'description', 'createActivation_description' - A user-defined description of the resource that you want to register
-- with Systems Manager.
--
-- Don\'t enter personally identifiable information in this field.
--
-- 'tags', 'createActivation_tags' - Optional metadata that you assign to a resource. Tags enable you to
-- categorize a resource in different ways, such as by purpose, owner, or
-- environment. For example, you might want to tag an activation to
-- identify which servers or virtual machines (VMs) in your on-premises
-- environment you intend to activate. In this case, you could specify the
-- following key-value pairs:
--
-- -   @Key=OS,Value=Windows@
--
-- -   @Key=Environment,Value=Production@
--
-- When you install SSM Agent on your on-premises servers and VMs, you
-- specify an activation ID and code. When you specify the activation ID
-- and code, tags assigned to the activation are automatically applied to
-- the on-premises servers or VMs.
--
-- You can\'t add tags to or delete tags from an existing activation. You
-- can tag your on-premises servers and VMs after they connect to Systems
-- Manager for the first time and are assigned a managed instance ID. This
-- means they are listed in the Amazon Web Services Systems Manager console
-- with an ID that is prefixed with \"mi-\". For information about how to
-- add tags to your managed instances, see AddTagsToResource. For
-- information about how to remove tags from your managed instances, see
-- RemoveTagsFromResource.
--
-- 'iamRole', 'createActivation_iamRole' - The name of the Identity and Access Management (IAM) role that you want
-- to assign to the managed instance. This IAM role must provide AssumeRole
-- permissions for the Amazon Web Services Systems Manager service
-- principal @ssm.amazonaws.com@. For more information, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-service-role.html Create an IAM service role for a hybrid environment>
-- in the /Amazon Web Services Systems Manager User Guide/.
newCreateActivation ::
  -- | 'iamRole'
  Prelude.Text ->
  CreateActivation
newCreateActivation :: Text -> CreateActivation
newCreateActivation Text
pIamRole_ =
  CreateActivation' :: Maybe Text
-> Maybe Natural
-> Maybe POSIX
-> Maybe Text
-> Maybe [Tag]
-> Text
-> CreateActivation
CreateActivation'
    { $sel:defaultInstanceName:CreateActivation' :: Maybe Text
defaultInstanceName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:registrationLimit:CreateActivation' :: Maybe Natural
registrationLimit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:expirationDate:CreateActivation' :: Maybe POSIX
expirationDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:description:CreateActivation' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateActivation' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:iamRole:CreateActivation' :: Text
iamRole = Text
pIamRole_
    }

-- | The name of the registered, managed instance as it will appear in the
-- Amazon Web Services Systems Manager console or when you use the Amazon
-- Web Services command line tools to list Systems Manager resources.
--
-- Don\'t enter personally identifiable information in this field.
createActivation_defaultInstanceName :: Lens.Lens' CreateActivation (Prelude.Maybe Prelude.Text)
createActivation_defaultInstanceName :: (Maybe Text -> f (Maybe Text))
-> CreateActivation -> f CreateActivation
createActivation_defaultInstanceName = (CreateActivation -> Maybe Text)
-> (CreateActivation -> Maybe Text -> CreateActivation)
-> Lens CreateActivation CreateActivation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateActivation' {Maybe Text
defaultInstanceName :: Maybe Text
$sel:defaultInstanceName:CreateActivation' :: CreateActivation -> Maybe Text
defaultInstanceName} -> Maybe Text
defaultInstanceName) (\s :: CreateActivation
s@CreateActivation' {} Maybe Text
a -> CreateActivation
s {$sel:defaultInstanceName:CreateActivation' :: Maybe Text
defaultInstanceName = Maybe Text
a} :: CreateActivation)

-- | Specify the maximum number of managed instances you want to register.
-- The default value is @1@.
createActivation_registrationLimit :: Lens.Lens' CreateActivation (Prelude.Maybe Prelude.Natural)
createActivation_registrationLimit :: (Maybe Natural -> f (Maybe Natural))
-> CreateActivation -> f CreateActivation
createActivation_registrationLimit = (CreateActivation -> Maybe Natural)
-> (CreateActivation -> Maybe Natural -> CreateActivation)
-> Lens
     CreateActivation CreateActivation (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateActivation' {Maybe Natural
registrationLimit :: Maybe Natural
$sel:registrationLimit:CreateActivation' :: CreateActivation -> Maybe Natural
registrationLimit} -> Maybe Natural
registrationLimit) (\s :: CreateActivation
s@CreateActivation' {} Maybe Natural
a -> CreateActivation
s {$sel:registrationLimit:CreateActivation' :: Maybe Natural
registrationLimit = Maybe Natural
a} :: CreateActivation)

-- | The date by which this activation request should expire, in timestamp
-- format, such as \"2021-07-07T00:00:00\". You can specify a date up to 30
-- days in advance. If you don\'t provide an expiration date, the
-- activation code expires in 24 hours.
createActivation_expirationDate :: Lens.Lens' CreateActivation (Prelude.Maybe Prelude.UTCTime)
createActivation_expirationDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> CreateActivation -> f CreateActivation
createActivation_expirationDate = (CreateActivation -> Maybe POSIX)
-> (CreateActivation -> Maybe POSIX -> CreateActivation)
-> Lens
     CreateActivation CreateActivation (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateActivation' {Maybe POSIX
expirationDate :: Maybe POSIX
$sel:expirationDate:CreateActivation' :: CreateActivation -> Maybe POSIX
expirationDate} -> Maybe POSIX
expirationDate) (\s :: CreateActivation
s@CreateActivation' {} Maybe POSIX
a -> CreateActivation
s {$sel:expirationDate:CreateActivation' :: Maybe POSIX
expirationDate = Maybe POSIX
a} :: CreateActivation) ((Maybe POSIX -> f (Maybe POSIX))
 -> CreateActivation -> f CreateActivation)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> CreateActivation
-> f CreateActivation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | A user-defined description of the resource that you want to register
-- with Systems Manager.
--
-- Don\'t enter personally identifiable information in this field.
createActivation_description :: Lens.Lens' CreateActivation (Prelude.Maybe Prelude.Text)
createActivation_description :: (Maybe Text -> f (Maybe Text))
-> CreateActivation -> f CreateActivation
createActivation_description = (CreateActivation -> Maybe Text)
-> (CreateActivation -> Maybe Text -> CreateActivation)
-> Lens CreateActivation CreateActivation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateActivation' {Maybe Text
description :: Maybe Text
$sel:description:CreateActivation' :: CreateActivation -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateActivation
s@CreateActivation' {} Maybe Text
a -> CreateActivation
s {$sel:description:CreateActivation' :: Maybe Text
description = Maybe Text
a} :: CreateActivation)

-- | Optional metadata that you assign to a resource. Tags enable you to
-- categorize a resource in different ways, such as by purpose, owner, or
-- environment. For example, you might want to tag an activation to
-- identify which servers or virtual machines (VMs) in your on-premises
-- environment you intend to activate. In this case, you could specify the
-- following key-value pairs:
--
-- -   @Key=OS,Value=Windows@
--
-- -   @Key=Environment,Value=Production@
--
-- When you install SSM Agent on your on-premises servers and VMs, you
-- specify an activation ID and code. When you specify the activation ID
-- and code, tags assigned to the activation are automatically applied to
-- the on-premises servers or VMs.
--
-- You can\'t add tags to or delete tags from an existing activation. You
-- can tag your on-premises servers and VMs after they connect to Systems
-- Manager for the first time and are assigned a managed instance ID. This
-- means they are listed in the Amazon Web Services Systems Manager console
-- with an ID that is prefixed with \"mi-\". For information about how to
-- add tags to your managed instances, see AddTagsToResource. For
-- information about how to remove tags from your managed instances, see
-- RemoveTagsFromResource.
createActivation_tags :: Lens.Lens' CreateActivation (Prelude.Maybe [Tag])
createActivation_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateActivation -> f CreateActivation
createActivation_tags = (CreateActivation -> Maybe [Tag])
-> (CreateActivation -> Maybe [Tag] -> CreateActivation)
-> Lens
     CreateActivation CreateActivation (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateActivation' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateActivation' :: CreateActivation -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateActivation
s@CreateActivation' {} Maybe [Tag]
a -> CreateActivation
s {$sel:tags:CreateActivation' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateActivation) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateActivation -> f CreateActivation)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateActivation
-> f CreateActivation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the Identity and Access Management (IAM) role that you want
-- to assign to the managed instance. This IAM role must provide AssumeRole
-- permissions for the Amazon Web Services Systems Manager service
-- principal @ssm.amazonaws.com@. For more information, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-service-role.html Create an IAM service role for a hybrid environment>
-- in the /Amazon Web Services Systems Manager User Guide/.
createActivation_iamRole :: Lens.Lens' CreateActivation Prelude.Text
createActivation_iamRole :: (Text -> f Text) -> CreateActivation -> f CreateActivation
createActivation_iamRole = (CreateActivation -> Text)
-> (CreateActivation -> Text -> CreateActivation)
-> Lens CreateActivation CreateActivation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateActivation' {Text
iamRole :: Text
$sel:iamRole:CreateActivation' :: CreateActivation -> Text
iamRole} -> Text
iamRole) (\s :: CreateActivation
s@CreateActivation' {} Text
a -> CreateActivation
s {$sel:iamRole:CreateActivation' :: Text
iamRole = Text
a} :: CreateActivation)

instance Core.AWSRequest CreateActivation where
  type
    AWSResponse CreateActivation =
      CreateActivationResponse
  request :: CreateActivation -> Request CreateActivation
request = Service -> CreateActivation -> Request CreateActivation
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateActivation
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateActivation)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateActivation))
-> Logger
-> Service
-> Proxy CreateActivation
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateActivation)))
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 -> Int -> CreateActivationResponse
CreateActivationResponse'
            (Maybe Text -> Maybe Text -> Int -> CreateActivationResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CreateActivationResponse)
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
"ActivationId")
            Either String (Maybe Text -> Int -> CreateActivationResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateActivationResponse)
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
"ActivationCode")
            Either String (Int -> CreateActivationResponse)
-> Either String Int -> Either String CreateActivationResponse
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 CreateActivation

instance Prelude.NFData CreateActivation

instance Core.ToHeaders CreateActivation where
  toHeaders :: CreateActivation -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateActivation -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"AmazonSSM.CreateActivation" :: Prelude.ByteString),
            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 CreateActivation where
  toJSON :: CreateActivation -> Value
toJSON CreateActivation' {Maybe Natural
Maybe [Tag]
Maybe Text
Maybe POSIX
Text
iamRole :: Text
tags :: Maybe [Tag]
description :: Maybe Text
expirationDate :: Maybe POSIX
registrationLimit :: Maybe Natural
defaultInstanceName :: Maybe Text
$sel:iamRole:CreateActivation' :: CreateActivation -> Text
$sel:tags:CreateActivation' :: CreateActivation -> Maybe [Tag]
$sel:description:CreateActivation' :: CreateActivation -> Maybe Text
$sel:expirationDate:CreateActivation' :: CreateActivation -> Maybe POSIX
$sel:registrationLimit:CreateActivation' :: CreateActivation -> Maybe Natural
$sel:defaultInstanceName:CreateActivation' :: CreateActivation -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DefaultInstanceName" 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
defaultInstanceName,
            (Text
"RegistrationLimit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
registrationLimit,
            (Text
"ExpirationDate" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
expirationDate,
            (Text
"Description" 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
description,
            (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"IamRole" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
iamRole)
          ]
      )

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

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

-- | /See:/ 'newCreateActivationResponse' smart constructor.
data CreateActivationResponse = CreateActivationResponse'
  { -- | The ID number generated by the system when it processed the activation.
    -- The activation ID functions like a user name.
    CreateActivationResponse -> Maybe Text
activationId :: Prelude.Maybe Prelude.Text,
    -- | The code the system generates when it processes the activation. The
    -- activation code functions like a password to validate the activation ID.
    CreateActivationResponse -> Maybe Text
activationCode :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateActivationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateActivationResponse -> CreateActivationResponse -> Bool
(CreateActivationResponse -> CreateActivationResponse -> Bool)
-> (CreateActivationResponse -> CreateActivationResponse -> Bool)
-> Eq CreateActivationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateActivationResponse -> CreateActivationResponse -> Bool
$c/= :: CreateActivationResponse -> CreateActivationResponse -> Bool
== :: CreateActivationResponse -> CreateActivationResponse -> Bool
$c== :: CreateActivationResponse -> CreateActivationResponse -> Bool
Prelude.Eq, ReadPrec [CreateActivationResponse]
ReadPrec CreateActivationResponse
Int -> ReadS CreateActivationResponse
ReadS [CreateActivationResponse]
(Int -> ReadS CreateActivationResponse)
-> ReadS [CreateActivationResponse]
-> ReadPrec CreateActivationResponse
-> ReadPrec [CreateActivationResponse]
-> Read CreateActivationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateActivationResponse]
$creadListPrec :: ReadPrec [CreateActivationResponse]
readPrec :: ReadPrec CreateActivationResponse
$creadPrec :: ReadPrec CreateActivationResponse
readList :: ReadS [CreateActivationResponse]
$creadList :: ReadS [CreateActivationResponse]
readsPrec :: Int -> ReadS CreateActivationResponse
$creadsPrec :: Int -> ReadS CreateActivationResponse
Prelude.Read, Int -> CreateActivationResponse -> ShowS
[CreateActivationResponse] -> ShowS
CreateActivationResponse -> String
(Int -> CreateActivationResponse -> ShowS)
-> (CreateActivationResponse -> String)
-> ([CreateActivationResponse] -> ShowS)
-> Show CreateActivationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateActivationResponse] -> ShowS
$cshowList :: [CreateActivationResponse] -> ShowS
show :: CreateActivationResponse -> String
$cshow :: CreateActivationResponse -> String
showsPrec :: Int -> CreateActivationResponse -> ShowS
$cshowsPrec :: Int -> CreateActivationResponse -> ShowS
Prelude.Show, (forall x.
 CreateActivationResponse -> Rep CreateActivationResponse x)
-> (forall x.
    Rep CreateActivationResponse x -> CreateActivationResponse)
-> Generic CreateActivationResponse
forall x.
Rep CreateActivationResponse x -> CreateActivationResponse
forall x.
CreateActivationResponse -> Rep CreateActivationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateActivationResponse x -> CreateActivationResponse
$cfrom :: forall x.
CreateActivationResponse -> Rep CreateActivationResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateActivationResponse' 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:
--
-- 'activationId', 'createActivationResponse_activationId' - The ID number generated by the system when it processed the activation.
-- The activation ID functions like a user name.
--
-- 'activationCode', 'createActivationResponse_activationCode' - The code the system generates when it processes the activation. The
-- activation code functions like a password to validate the activation ID.
--
-- 'httpStatus', 'createActivationResponse_httpStatus' - The response's http status code.
newCreateActivationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateActivationResponse
newCreateActivationResponse :: Int -> CreateActivationResponse
newCreateActivationResponse Int
pHttpStatus_ =
  CreateActivationResponse' :: Maybe Text -> Maybe Text -> Int -> CreateActivationResponse
CreateActivationResponse'
    { $sel:activationId:CreateActivationResponse' :: Maybe Text
activationId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:activationCode:CreateActivationResponse' :: Maybe Text
activationCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateActivationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ID number generated by the system when it processed the activation.
-- The activation ID functions like a user name.
createActivationResponse_activationId :: Lens.Lens' CreateActivationResponse (Prelude.Maybe Prelude.Text)
createActivationResponse_activationId :: (Maybe Text -> f (Maybe Text))
-> CreateActivationResponse -> f CreateActivationResponse
createActivationResponse_activationId = (CreateActivationResponse -> Maybe Text)
-> (CreateActivationResponse
    -> Maybe Text -> CreateActivationResponse)
-> Lens
     CreateActivationResponse
     CreateActivationResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateActivationResponse' {Maybe Text
activationId :: Maybe Text
$sel:activationId:CreateActivationResponse' :: CreateActivationResponse -> Maybe Text
activationId} -> Maybe Text
activationId) (\s :: CreateActivationResponse
s@CreateActivationResponse' {} Maybe Text
a -> CreateActivationResponse
s {$sel:activationId:CreateActivationResponse' :: Maybe Text
activationId = Maybe Text
a} :: CreateActivationResponse)

-- | The code the system generates when it processes the activation. The
-- activation code functions like a password to validate the activation ID.
createActivationResponse_activationCode :: Lens.Lens' CreateActivationResponse (Prelude.Maybe Prelude.Text)
createActivationResponse_activationCode :: (Maybe Text -> f (Maybe Text))
-> CreateActivationResponse -> f CreateActivationResponse
createActivationResponse_activationCode = (CreateActivationResponse -> Maybe Text)
-> (CreateActivationResponse
    -> Maybe Text -> CreateActivationResponse)
-> Lens
     CreateActivationResponse
     CreateActivationResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateActivationResponse' {Maybe Text
activationCode :: Maybe Text
$sel:activationCode:CreateActivationResponse' :: CreateActivationResponse -> Maybe Text
activationCode} -> Maybe Text
activationCode) (\s :: CreateActivationResponse
s@CreateActivationResponse' {} Maybe Text
a -> CreateActivationResponse
s {$sel:activationCode:CreateActivationResponse' :: Maybe Text
activationCode = Maybe Text
a} :: CreateActivationResponse)

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

instance Prelude.NFData CreateActivationResponse