{-# 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.CodeDeploy.RegisterOnPremisesInstance
-- 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)
--
-- Registers an on-premises instance.
--
-- Only one IAM ARN (an IAM session ARN or IAM user ARN) is supported in
-- the request. You cannot use both.
module Amazonka.CodeDeploy.RegisterOnPremisesInstance
  ( -- * Creating a Request
    RegisterOnPremisesInstance (..),
    newRegisterOnPremisesInstance,

    -- * Request Lenses
    registerOnPremisesInstance_iamUserArn,
    registerOnPremisesInstance_iamSessionArn,
    registerOnPremisesInstance_instanceName,

    -- * Destructuring the Response
    RegisterOnPremisesInstanceResponse (..),
    newRegisterOnPremisesInstanceResponse,
  )
where

import Amazonka.CodeDeploy.Types
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

-- | Represents the input of the register on-premises instance operation.
--
-- /See:/ 'newRegisterOnPremisesInstance' smart constructor.
data RegisterOnPremisesInstance = RegisterOnPremisesInstance'
  { -- | The ARN of the IAM user to associate with the on-premises instance.
    RegisterOnPremisesInstance -> Maybe Text
iamUserArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the IAM session to associate with the on-premises instance.
    RegisterOnPremisesInstance -> Maybe Text
iamSessionArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the on-premises instance to register.
    RegisterOnPremisesInstance -> Text
instanceName :: Prelude.Text
  }
  deriving (RegisterOnPremisesInstance -> RegisterOnPremisesInstance -> Bool
(RegisterOnPremisesInstance -> RegisterOnPremisesInstance -> Bool)
-> (RegisterOnPremisesInstance
    -> RegisterOnPremisesInstance -> Bool)
-> Eq RegisterOnPremisesInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterOnPremisesInstance -> RegisterOnPremisesInstance -> Bool
$c/= :: RegisterOnPremisesInstance -> RegisterOnPremisesInstance -> Bool
== :: RegisterOnPremisesInstance -> RegisterOnPremisesInstance -> Bool
$c== :: RegisterOnPremisesInstance -> RegisterOnPremisesInstance -> Bool
Prelude.Eq, ReadPrec [RegisterOnPremisesInstance]
ReadPrec RegisterOnPremisesInstance
Int -> ReadS RegisterOnPremisesInstance
ReadS [RegisterOnPremisesInstance]
(Int -> ReadS RegisterOnPremisesInstance)
-> ReadS [RegisterOnPremisesInstance]
-> ReadPrec RegisterOnPremisesInstance
-> ReadPrec [RegisterOnPremisesInstance]
-> Read RegisterOnPremisesInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterOnPremisesInstance]
$creadListPrec :: ReadPrec [RegisterOnPremisesInstance]
readPrec :: ReadPrec RegisterOnPremisesInstance
$creadPrec :: ReadPrec RegisterOnPremisesInstance
readList :: ReadS [RegisterOnPremisesInstance]
$creadList :: ReadS [RegisterOnPremisesInstance]
readsPrec :: Int -> ReadS RegisterOnPremisesInstance
$creadsPrec :: Int -> ReadS RegisterOnPremisesInstance
Prelude.Read, Int -> RegisterOnPremisesInstance -> ShowS
[RegisterOnPremisesInstance] -> ShowS
RegisterOnPremisesInstance -> String
(Int -> RegisterOnPremisesInstance -> ShowS)
-> (RegisterOnPremisesInstance -> String)
-> ([RegisterOnPremisesInstance] -> ShowS)
-> Show RegisterOnPremisesInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterOnPremisesInstance] -> ShowS
$cshowList :: [RegisterOnPremisesInstance] -> ShowS
show :: RegisterOnPremisesInstance -> String
$cshow :: RegisterOnPremisesInstance -> String
showsPrec :: Int -> RegisterOnPremisesInstance -> ShowS
$cshowsPrec :: Int -> RegisterOnPremisesInstance -> ShowS
Prelude.Show, (forall x.
 RegisterOnPremisesInstance -> Rep RegisterOnPremisesInstance x)
-> (forall x.
    Rep RegisterOnPremisesInstance x -> RegisterOnPremisesInstance)
-> Generic RegisterOnPremisesInstance
forall x.
Rep RegisterOnPremisesInstance x -> RegisterOnPremisesInstance
forall x.
RegisterOnPremisesInstance -> Rep RegisterOnPremisesInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RegisterOnPremisesInstance x -> RegisterOnPremisesInstance
$cfrom :: forall x.
RegisterOnPremisesInstance -> Rep RegisterOnPremisesInstance x
Prelude.Generic)

-- |
-- Create a value of 'RegisterOnPremisesInstance' 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:
--
-- 'iamUserArn', 'registerOnPremisesInstance_iamUserArn' - The ARN of the IAM user to associate with the on-premises instance.
--
-- 'iamSessionArn', 'registerOnPremisesInstance_iamSessionArn' - The ARN of the IAM session to associate with the on-premises instance.
--
-- 'instanceName', 'registerOnPremisesInstance_instanceName' - The name of the on-premises instance to register.
newRegisterOnPremisesInstance ::
  -- | 'instanceName'
  Prelude.Text ->
  RegisterOnPremisesInstance
newRegisterOnPremisesInstance :: Text -> RegisterOnPremisesInstance
newRegisterOnPremisesInstance Text
pInstanceName_ =
  RegisterOnPremisesInstance' :: Maybe Text -> Maybe Text -> Text -> RegisterOnPremisesInstance
RegisterOnPremisesInstance'
    { $sel:iamUserArn:RegisterOnPremisesInstance' :: Maybe Text
iamUserArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:iamSessionArn:RegisterOnPremisesInstance' :: Maybe Text
iamSessionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceName:RegisterOnPremisesInstance' :: Text
instanceName = Text
pInstanceName_
    }

-- | The ARN of the IAM user to associate with the on-premises instance.
registerOnPremisesInstance_iamUserArn :: Lens.Lens' RegisterOnPremisesInstance (Prelude.Maybe Prelude.Text)
registerOnPremisesInstance_iamUserArn :: (Maybe Text -> f (Maybe Text))
-> RegisterOnPremisesInstance -> f RegisterOnPremisesInstance
registerOnPremisesInstance_iamUserArn = (RegisterOnPremisesInstance -> Maybe Text)
-> (RegisterOnPremisesInstance
    -> Maybe Text -> RegisterOnPremisesInstance)
-> Lens
     RegisterOnPremisesInstance
     RegisterOnPremisesInstance
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterOnPremisesInstance' {Maybe Text
iamUserArn :: Maybe Text
$sel:iamUserArn:RegisterOnPremisesInstance' :: RegisterOnPremisesInstance -> Maybe Text
iamUserArn} -> Maybe Text
iamUserArn) (\s :: RegisterOnPremisesInstance
s@RegisterOnPremisesInstance' {} Maybe Text
a -> RegisterOnPremisesInstance
s {$sel:iamUserArn:RegisterOnPremisesInstance' :: Maybe Text
iamUserArn = Maybe Text
a} :: RegisterOnPremisesInstance)

-- | The ARN of the IAM session to associate with the on-premises instance.
registerOnPremisesInstance_iamSessionArn :: Lens.Lens' RegisterOnPremisesInstance (Prelude.Maybe Prelude.Text)
registerOnPremisesInstance_iamSessionArn :: (Maybe Text -> f (Maybe Text))
-> RegisterOnPremisesInstance -> f RegisterOnPremisesInstance
registerOnPremisesInstance_iamSessionArn = (RegisterOnPremisesInstance -> Maybe Text)
-> (RegisterOnPremisesInstance
    -> Maybe Text -> RegisterOnPremisesInstance)
-> Lens
     RegisterOnPremisesInstance
     RegisterOnPremisesInstance
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterOnPremisesInstance' {Maybe Text
iamSessionArn :: Maybe Text
$sel:iamSessionArn:RegisterOnPremisesInstance' :: RegisterOnPremisesInstance -> Maybe Text
iamSessionArn} -> Maybe Text
iamSessionArn) (\s :: RegisterOnPremisesInstance
s@RegisterOnPremisesInstance' {} Maybe Text
a -> RegisterOnPremisesInstance
s {$sel:iamSessionArn:RegisterOnPremisesInstance' :: Maybe Text
iamSessionArn = Maybe Text
a} :: RegisterOnPremisesInstance)

-- | The name of the on-premises instance to register.
registerOnPremisesInstance_instanceName :: Lens.Lens' RegisterOnPremisesInstance Prelude.Text
registerOnPremisesInstance_instanceName :: (Text -> f Text)
-> RegisterOnPremisesInstance -> f RegisterOnPremisesInstance
registerOnPremisesInstance_instanceName = (RegisterOnPremisesInstance -> Text)
-> (RegisterOnPremisesInstance
    -> Text -> RegisterOnPremisesInstance)
-> Lens
     RegisterOnPremisesInstance RegisterOnPremisesInstance Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterOnPremisesInstance' {Text
instanceName :: Text
$sel:instanceName:RegisterOnPremisesInstance' :: RegisterOnPremisesInstance -> Text
instanceName} -> Text
instanceName) (\s :: RegisterOnPremisesInstance
s@RegisterOnPremisesInstance' {} Text
a -> RegisterOnPremisesInstance
s {$sel:instanceName:RegisterOnPremisesInstance' :: Text
instanceName = Text
a} :: RegisterOnPremisesInstance)

instance Core.AWSRequest RegisterOnPremisesInstance where
  type
    AWSResponse RegisterOnPremisesInstance =
      RegisterOnPremisesInstanceResponse
  request :: RegisterOnPremisesInstance -> Request RegisterOnPremisesInstance
request = Service
-> RegisterOnPremisesInstance -> Request RegisterOnPremisesInstance
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RegisterOnPremisesInstance
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RegisterOnPremisesInstance)))
response =
    AWSResponse RegisterOnPremisesInstance
-> Logger
-> Service
-> Proxy RegisterOnPremisesInstance
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RegisterOnPremisesInstance)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse RegisterOnPremisesInstance
RegisterOnPremisesInstanceResponse
RegisterOnPremisesInstanceResponse'

instance Prelude.Hashable RegisterOnPremisesInstance

instance Prelude.NFData RegisterOnPremisesInstance

instance Core.ToHeaders RegisterOnPremisesInstance where
  toHeaders :: RegisterOnPremisesInstance -> [Header]
toHeaders =
    [Header] -> RegisterOnPremisesInstance -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"CodeDeploy_20141006.RegisterOnPremisesInstance" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON RegisterOnPremisesInstance where
  toJSON :: RegisterOnPremisesInstance -> Value
toJSON RegisterOnPremisesInstance' {Maybe Text
Text
instanceName :: Text
iamSessionArn :: Maybe Text
iamUserArn :: Maybe Text
$sel:instanceName:RegisterOnPremisesInstance' :: RegisterOnPremisesInstance -> Text
$sel:iamSessionArn:RegisterOnPremisesInstance' :: RegisterOnPremisesInstance -> Maybe Text
$sel:iamUserArn:RegisterOnPremisesInstance' :: RegisterOnPremisesInstance -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"iamUserArn" 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
iamUserArn,
            (Text
"iamSessionArn" 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
iamSessionArn,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"instanceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceName)
          ]
      )

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

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

-- | /See:/ 'newRegisterOnPremisesInstanceResponse' smart constructor.
data RegisterOnPremisesInstanceResponse = RegisterOnPremisesInstanceResponse'
  {
  }
  deriving (RegisterOnPremisesInstanceResponse
-> RegisterOnPremisesInstanceResponse -> Bool
(RegisterOnPremisesInstanceResponse
 -> RegisterOnPremisesInstanceResponse -> Bool)
-> (RegisterOnPremisesInstanceResponse
    -> RegisterOnPremisesInstanceResponse -> Bool)
-> Eq RegisterOnPremisesInstanceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterOnPremisesInstanceResponse
-> RegisterOnPremisesInstanceResponse -> Bool
$c/= :: RegisterOnPremisesInstanceResponse
-> RegisterOnPremisesInstanceResponse -> Bool
== :: RegisterOnPremisesInstanceResponse
-> RegisterOnPremisesInstanceResponse -> Bool
$c== :: RegisterOnPremisesInstanceResponse
-> RegisterOnPremisesInstanceResponse -> Bool
Prelude.Eq, ReadPrec [RegisterOnPremisesInstanceResponse]
ReadPrec RegisterOnPremisesInstanceResponse
Int -> ReadS RegisterOnPremisesInstanceResponse
ReadS [RegisterOnPremisesInstanceResponse]
(Int -> ReadS RegisterOnPremisesInstanceResponse)
-> ReadS [RegisterOnPremisesInstanceResponse]
-> ReadPrec RegisterOnPremisesInstanceResponse
-> ReadPrec [RegisterOnPremisesInstanceResponse]
-> Read RegisterOnPremisesInstanceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterOnPremisesInstanceResponse]
$creadListPrec :: ReadPrec [RegisterOnPremisesInstanceResponse]
readPrec :: ReadPrec RegisterOnPremisesInstanceResponse
$creadPrec :: ReadPrec RegisterOnPremisesInstanceResponse
readList :: ReadS [RegisterOnPremisesInstanceResponse]
$creadList :: ReadS [RegisterOnPremisesInstanceResponse]
readsPrec :: Int -> ReadS RegisterOnPremisesInstanceResponse
$creadsPrec :: Int -> ReadS RegisterOnPremisesInstanceResponse
Prelude.Read, Int -> RegisterOnPremisesInstanceResponse -> ShowS
[RegisterOnPremisesInstanceResponse] -> ShowS
RegisterOnPremisesInstanceResponse -> String
(Int -> RegisterOnPremisesInstanceResponse -> ShowS)
-> (RegisterOnPremisesInstanceResponse -> String)
-> ([RegisterOnPremisesInstanceResponse] -> ShowS)
-> Show RegisterOnPremisesInstanceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterOnPremisesInstanceResponse] -> ShowS
$cshowList :: [RegisterOnPremisesInstanceResponse] -> ShowS
show :: RegisterOnPremisesInstanceResponse -> String
$cshow :: RegisterOnPremisesInstanceResponse -> String
showsPrec :: Int -> RegisterOnPremisesInstanceResponse -> ShowS
$cshowsPrec :: Int -> RegisterOnPremisesInstanceResponse -> ShowS
Prelude.Show, (forall x.
 RegisterOnPremisesInstanceResponse
 -> Rep RegisterOnPremisesInstanceResponse x)
-> (forall x.
    Rep RegisterOnPremisesInstanceResponse x
    -> RegisterOnPremisesInstanceResponse)
-> Generic RegisterOnPremisesInstanceResponse
forall x.
Rep RegisterOnPremisesInstanceResponse x
-> RegisterOnPremisesInstanceResponse
forall x.
RegisterOnPremisesInstanceResponse
-> Rep RegisterOnPremisesInstanceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RegisterOnPremisesInstanceResponse x
-> RegisterOnPremisesInstanceResponse
$cfrom :: forall x.
RegisterOnPremisesInstanceResponse
-> Rep RegisterOnPremisesInstanceResponse x
Prelude.Generic)

-- |
-- Create a value of 'RegisterOnPremisesInstanceResponse' 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.
newRegisterOnPremisesInstanceResponse ::
  RegisterOnPremisesInstanceResponse
newRegisterOnPremisesInstanceResponse :: RegisterOnPremisesInstanceResponse
newRegisterOnPremisesInstanceResponse =
  RegisterOnPremisesInstanceResponse
RegisterOnPremisesInstanceResponse'

instance
  Prelude.NFData
    RegisterOnPremisesInstanceResponse