{-# 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.ElasticBeanstalk.AssociateEnvironmentOperationsRole
-- 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)
--
-- Add or change the operations role used by an environment. After this
-- call is made, Elastic Beanstalk uses the associated operations role for
-- permissions to downstream services during subsequent calls acting on
-- this environment. For more information, see
-- <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/iam-operationsrole.html Operations roles>
-- in the /AWS Elastic Beanstalk Developer Guide/.
module Amazonka.ElasticBeanstalk.AssociateEnvironmentOperationsRole
  ( -- * Creating a Request
    AssociateEnvironmentOperationsRole (..),
    newAssociateEnvironmentOperationsRole,

    -- * Request Lenses
    associateEnvironmentOperationsRole_environmentName,
    associateEnvironmentOperationsRole_operationsRole,

    -- * Destructuring the Response
    AssociateEnvironmentOperationsRoleResponse (..),
    newAssociateEnvironmentOperationsRoleResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ElasticBeanstalk.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

-- | Request to add or change the operations role used by an environment.
--
-- /See:/ 'newAssociateEnvironmentOperationsRole' smart constructor.
data AssociateEnvironmentOperationsRole = AssociateEnvironmentOperationsRole'
  { -- | The name of the environment to which to set the operations role.
    AssociateEnvironmentOperationsRole -> Text
environmentName :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of an existing IAM role to be used as the
    -- environment\'s operations role.
    AssociateEnvironmentOperationsRole -> Text
operationsRole :: Prelude.Text
  }
  deriving (AssociateEnvironmentOperationsRole
-> AssociateEnvironmentOperationsRole -> Bool
(AssociateEnvironmentOperationsRole
 -> AssociateEnvironmentOperationsRole -> Bool)
-> (AssociateEnvironmentOperationsRole
    -> AssociateEnvironmentOperationsRole -> Bool)
-> Eq AssociateEnvironmentOperationsRole
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateEnvironmentOperationsRole
-> AssociateEnvironmentOperationsRole -> Bool
$c/= :: AssociateEnvironmentOperationsRole
-> AssociateEnvironmentOperationsRole -> Bool
== :: AssociateEnvironmentOperationsRole
-> AssociateEnvironmentOperationsRole -> Bool
$c== :: AssociateEnvironmentOperationsRole
-> AssociateEnvironmentOperationsRole -> Bool
Prelude.Eq, ReadPrec [AssociateEnvironmentOperationsRole]
ReadPrec AssociateEnvironmentOperationsRole
Int -> ReadS AssociateEnvironmentOperationsRole
ReadS [AssociateEnvironmentOperationsRole]
(Int -> ReadS AssociateEnvironmentOperationsRole)
-> ReadS [AssociateEnvironmentOperationsRole]
-> ReadPrec AssociateEnvironmentOperationsRole
-> ReadPrec [AssociateEnvironmentOperationsRole]
-> Read AssociateEnvironmentOperationsRole
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateEnvironmentOperationsRole]
$creadListPrec :: ReadPrec [AssociateEnvironmentOperationsRole]
readPrec :: ReadPrec AssociateEnvironmentOperationsRole
$creadPrec :: ReadPrec AssociateEnvironmentOperationsRole
readList :: ReadS [AssociateEnvironmentOperationsRole]
$creadList :: ReadS [AssociateEnvironmentOperationsRole]
readsPrec :: Int -> ReadS AssociateEnvironmentOperationsRole
$creadsPrec :: Int -> ReadS AssociateEnvironmentOperationsRole
Prelude.Read, Int -> AssociateEnvironmentOperationsRole -> ShowS
[AssociateEnvironmentOperationsRole] -> ShowS
AssociateEnvironmentOperationsRole -> String
(Int -> AssociateEnvironmentOperationsRole -> ShowS)
-> (AssociateEnvironmentOperationsRole -> String)
-> ([AssociateEnvironmentOperationsRole] -> ShowS)
-> Show AssociateEnvironmentOperationsRole
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateEnvironmentOperationsRole] -> ShowS
$cshowList :: [AssociateEnvironmentOperationsRole] -> ShowS
show :: AssociateEnvironmentOperationsRole -> String
$cshow :: AssociateEnvironmentOperationsRole -> String
showsPrec :: Int -> AssociateEnvironmentOperationsRole -> ShowS
$cshowsPrec :: Int -> AssociateEnvironmentOperationsRole -> ShowS
Prelude.Show, (forall x.
 AssociateEnvironmentOperationsRole
 -> Rep AssociateEnvironmentOperationsRole x)
-> (forall x.
    Rep AssociateEnvironmentOperationsRole x
    -> AssociateEnvironmentOperationsRole)
-> Generic AssociateEnvironmentOperationsRole
forall x.
Rep AssociateEnvironmentOperationsRole x
-> AssociateEnvironmentOperationsRole
forall x.
AssociateEnvironmentOperationsRole
-> Rep AssociateEnvironmentOperationsRole x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateEnvironmentOperationsRole x
-> AssociateEnvironmentOperationsRole
$cfrom :: forall x.
AssociateEnvironmentOperationsRole
-> Rep AssociateEnvironmentOperationsRole x
Prelude.Generic)

-- |
-- Create a value of 'AssociateEnvironmentOperationsRole' 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:
--
-- 'environmentName', 'associateEnvironmentOperationsRole_environmentName' - The name of the environment to which to set the operations role.
--
-- 'operationsRole', 'associateEnvironmentOperationsRole_operationsRole' - The Amazon Resource Name (ARN) of an existing IAM role to be used as the
-- environment\'s operations role.
newAssociateEnvironmentOperationsRole ::
  -- | 'environmentName'
  Prelude.Text ->
  -- | 'operationsRole'
  Prelude.Text ->
  AssociateEnvironmentOperationsRole
newAssociateEnvironmentOperationsRole :: Text -> Text -> AssociateEnvironmentOperationsRole
newAssociateEnvironmentOperationsRole
  Text
pEnvironmentName_
  Text
pOperationsRole_ =
    AssociateEnvironmentOperationsRole' :: Text -> Text -> AssociateEnvironmentOperationsRole
AssociateEnvironmentOperationsRole'
      { $sel:environmentName:AssociateEnvironmentOperationsRole' :: Text
environmentName =
          Text
pEnvironmentName_,
        $sel:operationsRole:AssociateEnvironmentOperationsRole' :: Text
operationsRole = Text
pOperationsRole_
      }

-- | The name of the environment to which to set the operations role.
associateEnvironmentOperationsRole_environmentName :: Lens.Lens' AssociateEnvironmentOperationsRole Prelude.Text
associateEnvironmentOperationsRole_environmentName :: (Text -> f Text)
-> AssociateEnvironmentOperationsRole
-> f AssociateEnvironmentOperationsRole
associateEnvironmentOperationsRole_environmentName = (AssociateEnvironmentOperationsRole -> Text)
-> (AssociateEnvironmentOperationsRole
    -> Text -> AssociateEnvironmentOperationsRole)
-> Lens
     AssociateEnvironmentOperationsRole
     AssociateEnvironmentOperationsRole
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateEnvironmentOperationsRole' {Text
environmentName :: Text
$sel:environmentName:AssociateEnvironmentOperationsRole' :: AssociateEnvironmentOperationsRole -> Text
environmentName} -> Text
environmentName) (\s :: AssociateEnvironmentOperationsRole
s@AssociateEnvironmentOperationsRole' {} Text
a -> AssociateEnvironmentOperationsRole
s {$sel:environmentName:AssociateEnvironmentOperationsRole' :: Text
environmentName = Text
a} :: AssociateEnvironmentOperationsRole)

-- | The Amazon Resource Name (ARN) of an existing IAM role to be used as the
-- environment\'s operations role.
associateEnvironmentOperationsRole_operationsRole :: Lens.Lens' AssociateEnvironmentOperationsRole Prelude.Text
associateEnvironmentOperationsRole_operationsRole :: (Text -> f Text)
-> AssociateEnvironmentOperationsRole
-> f AssociateEnvironmentOperationsRole
associateEnvironmentOperationsRole_operationsRole = (AssociateEnvironmentOperationsRole -> Text)
-> (AssociateEnvironmentOperationsRole
    -> Text -> AssociateEnvironmentOperationsRole)
-> Lens
     AssociateEnvironmentOperationsRole
     AssociateEnvironmentOperationsRole
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateEnvironmentOperationsRole' {Text
operationsRole :: Text
$sel:operationsRole:AssociateEnvironmentOperationsRole' :: AssociateEnvironmentOperationsRole -> Text
operationsRole} -> Text
operationsRole) (\s :: AssociateEnvironmentOperationsRole
s@AssociateEnvironmentOperationsRole' {} Text
a -> AssociateEnvironmentOperationsRole
s {$sel:operationsRole:AssociateEnvironmentOperationsRole' :: Text
operationsRole = Text
a} :: AssociateEnvironmentOperationsRole)

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

instance
  Prelude.Hashable
    AssociateEnvironmentOperationsRole

instance
  Prelude.NFData
    AssociateEnvironmentOperationsRole

instance
  Core.ToHeaders
    AssociateEnvironmentOperationsRole
  where
  toHeaders :: AssociateEnvironmentOperationsRole -> [Header]
toHeaders = [Header] -> AssociateEnvironmentOperationsRole -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

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

instance
  Core.ToQuery
    AssociateEnvironmentOperationsRole
  where
  toQuery :: AssociateEnvironmentOperationsRole -> QueryString
toQuery AssociateEnvironmentOperationsRole' {Text
operationsRole :: Text
environmentName :: Text
$sel:operationsRole:AssociateEnvironmentOperationsRole' :: AssociateEnvironmentOperationsRole -> Text
$sel:environmentName:AssociateEnvironmentOperationsRole' :: AssociateEnvironmentOperationsRole -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ( ByteString
"AssociateEnvironmentOperationsRole" ::
                      Prelude.ByteString
                  ),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"EnvironmentName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
environmentName,
        ByteString
"OperationsRole" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
operationsRole
      ]

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

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

instance
  Prelude.NFData
    AssociateEnvironmentOperationsRoleResponse