{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.EC2.Types.AssociatedRole
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EC2.Types.AssociatedRole where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import qualified Amazonka.Prelude as Prelude

-- | Information about the associated IAM roles.
--
-- /See:/ 'newAssociatedRole' smart constructor.
data AssociatedRole = AssociatedRole'
  { -- | The ARN of the associated IAM role.
    AssociatedRole -> Maybe Text
associatedRoleArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon S3 bucket in which the Amazon S3 object is
    -- stored.
    AssociatedRole -> Maybe Text
certificateS3BucketName :: Prelude.Maybe Prelude.Text,
    -- | The key of the Amazon S3 object ey where the certificate, certificate
    -- chain, and encrypted private key bundle is stored. The object key is
    -- formated as follows: @role_arn@\/@certificate_arn@.
    AssociatedRole -> Maybe Text
certificateS3ObjectKey :: Prelude.Maybe Prelude.Text,
    -- | The ID of the KMS customer master key (CMK) used to encrypt the private
    -- key.
    AssociatedRole -> Maybe Text
encryptionKmsKeyId :: Prelude.Maybe Prelude.Text
  }
  deriving (AssociatedRole -> AssociatedRole -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociatedRole -> AssociatedRole -> Bool
$c/= :: AssociatedRole -> AssociatedRole -> Bool
== :: AssociatedRole -> AssociatedRole -> Bool
$c== :: AssociatedRole -> AssociatedRole -> Bool
Prelude.Eq, ReadPrec [AssociatedRole]
ReadPrec AssociatedRole
Int -> ReadS AssociatedRole
ReadS [AssociatedRole]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociatedRole]
$creadListPrec :: ReadPrec [AssociatedRole]
readPrec :: ReadPrec AssociatedRole
$creadPrec :: ReadPrec AssociatedRole
readList :: ReadS [AssociatedRole]
$creadList :: ReadS [AssociatedRole]
readsPrec :: Int -> ReadS AssociatedRole
$creadsPrec :: Int -> ReadS AssociatedRole
Prelude.Read, Int -> AssociatedRole -> ShowS
[AssociatedRole] -> ShowS
AssociatedRole -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociatedRole] -> ShowS
$cshowList :: [AssociatedRole] -> ShowS
show :: AssociatedRole -> String
$cshow :: AssociatedRole -> String
showsPrec :: Int -> AssociatedRole -> ShowS
$cshowsPrec :: Int -> AssociatedRole -> ShowS
Prelude.Show, forall x. Rep AssociatedRole x -> AssociatedRole
forall x. AssociatedRole -> Rep AssociatedRole x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociatedRole x -> AssociatedRole
$cfrom :: forall x. AssociatedRole -> Rep AssociatedRole x
Prelude.Generic)

-- |
-- Create a value of 'AssociatedRole' 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:
--
-- 'associatedRoleArn', 'associatedRole_associatedRoleArn' - The ARN of the associated IAM role.
--
-- 'certificateS3BucketName', 'associatedRole_certificateS3BucketName' - The name of the Amazon S3 bucket in which the Amazon S3 object is
-- stored.
--
-- 'certificateS3ObjectKey', 'associatedRole_certificateS3ObjectKey' - The key of the Amazon S3 object ey where the certificate, certificate
-- chain, and encrypted private key bundle is stored. The object key is
-- formated as follows: @role_arn@\/@certificate_arn@.
--
-- 'encryptionKmsKeyId', 'associatedRole_encryptionKmsKeyId' - The ID of the KMS customer master key (CMK) used to encrypt the private
-- key.
newAssociatedRole ::
  AssociatedRole
newAssociatedRole :: AssociatedRole
newAssociatedRole =
  AssociatedRole'
    { $sel:associatedRoleArn:AssociatedRole' :: Maybe Text
associatedRoleArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:certificateS3BucketName:AssociatedRole' :: Maybe Text
certificateS3BucketName = forall a. Maybe a
Prelude.Nothing,
      $sel:certificateS3ObjectKey:AssociatedRole' :: Maybe Text
certificateS3ObjectKey = forall a. Maybe a
Prelude.Nothing,
      $sel:encryptionKmsKeyId:AssociatedRole' :: Maybe Text
encryptionKmsKeyId = forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the associated IAM role.
associatedRole_associatedRoleArn :: Lens.Lens' AssociatedRole (Prelude.Maybe Prelude.Text)
associatedRole_associatedRoleArn :: Lens' AssociatedRole (Maybe Text)
associatedRole_associatedRoleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociatedRole' {Maybe Text
associatedRoleArn :: Maybe Text
$sel:associatedRoleArn:AssociatedRole' :: AssociatedRole -> Maybe Text
associatedRoleArn} -> Maybe Text
associatedRoleArn) (\s :: AssociatedRole
s@AssociatedRole' {} Maybe Text
a -> AssociatedRole
s {$sel:associatedRoleArn:AssociatedRole' :: Maybe Text
associatedRoleArn = Maybe Text
a} :: AssociatedRole)

-- | The name of the Amazon S3 bucket in which the Amazon S3 object is
-- stored.
associatedRole_certificateS3BucketName :: Lens.Lens' AssociatedRole (Prelude.Maybe Prelude.Text)
associatedRole_certificateS3BucketName :: Lens' AssociatedRole (Maybe Text)
associatedRole_certificateS3BucketName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociatedRole' {Maybe Text
certificateS3BucketName :: Maybe Text
$sel:certificateS3BucketName:AssociatedRole' :: AssociatedRole -> Maybe Text
certificateS3BucketName} -> Maybe Text
certificateS3BucketName) (\s :: AssociatedRole
s@AssociatedRole' {} Maybe Text
a -> AssociatedRole
s {$sel:certificateS3BucketName:AssociatedRole' :: Maybe Text
certificateS3BucketName = Maybe Text
a} :: AssociatedRole)

-- | The key of the Amazon S3 object ey where the certificate, certificate
-- chain, and encrypted private key bundle is stored. The object key is
-- formated as follows: @role_arn@\/@certificate_arn@.
associatedRole_certificateS3ObjectKey :: Lens.Lens' AssociatedRole (Prelude.Maybe Prelude.Text)
associatedRole_certificateS3ObjectKey :: Lens' AssociatedRole (Maybe Text)
associatedRole_certificateS3ObjectKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociatedRole' {Maybe Text
certificateS3ObjectKey :: Maybe Text
$sel:certificateS3ObjectKey:AssociatedRole' :: AssociatedRole -> Maybe Text
certificateS3ObjectKey} -> Maybe Text
certificateS3ObjectKey) (\s :: AssociatedRole
s@AssociatedRole' {} Maybe Text
a -> AssociatedRole
s {$sel:certificateS3ObjectKey:AssociatedRole' :: Maybe Text
certificateS3ObjectKey = Maybe Text
a} :: AssociatedRole)

-- | The ID of the KMS customer master key (CMK) used to encrypt the private
-- key.
associatedRole_encryptionKmsKeyId :: Lens.Lens' AssociatedRole (Prelude.Maybe Prelude.Text)
associatedRole_encryptionKmsKeyId :: Lens' AssociatedRole (Maybe Text)
associatedRole_encryptionKmsKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociatedRole' {Maybe Text
encryptionKmsKeyId :: Maybe Text
$sel:encryptionKmsKeyId:AssociatedRole' :: AssociatedRole -> Maybe Text
encryptionKmsKeyId} -> Maybe Text
encryptionKmsKeyId) (\s :: AssociatedRole
s@AssociatedRole' {} Maybe Text
a -> AssociatedRole
s {$sel:encryptionKmsKeyId:AssociatedRole' :: Maybe Text
encryptionKmsKeyId = Maybe Text
a} :: AssociatedRole)

instance Data.FromXML AssociatedRole where
  parseXML :: [Node] -> Either String AssociatedRole
parseXML [Node]
x =
    Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> AssociatedRole
AssociatedRole'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"associatedRoleArn")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"certificateS3BucketName")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"certificateS3ObjectKey")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"encryptionKmsKeyId")

instance Prelude.Hashable AssociatedRole where
  hashWithSalt :: Int -> AssociatedRole -> Int
hashWithSalt Int
_salt AssociatedRole' {Maybe Text
encryptionKmsKeyId :: Maybe Text
certificateS3ObjectKey :: Maybe Text
certificateS3BucketName :: Maybe Text
associatedRoleArn :: Maybe Text
$sel:encryptionKmsKeyId:AssociatedRole' :: AssociatedRole -> Maybe Text
$sel:certificateS3ObjectKey:AssociatedRole' :: AssociatedRole -> Maybe Text
$sel:certificateS3BucketName:AssociatedRole' :: AssociatedRole -> Maybe Text
$sel:associatedRoleArn:AssociatedRole' :: AssociatedRole -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
associatedRoleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
certificateS3BucketName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
certificateS3ObjectKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
encryptionKmsKeyId

instance Prelude.NFData AssociatedRole where
  rnf :: AssociatedRole -> ()
rnf AssociatedRole' {Maybe Text
encryptionKmsKeyId :: Maybe Text
certificateS3ObjectKey :: Maybe Text
certificateS3BucketName :: Maybe Text
associatedRoleArn :: Maybe Text
$sel:encryptionKmsKeyId:AssociatedRole' :: AssociatedRole -> Maybe Text
$sel:certificateS3ObjectKey:AssociatedRole' :: AssociatedRole -> Maybe Text
$sel:certificateS3BucketName:AssociatedRole' :: AssociatedRole -> Maybe Text
$sel:associatedRoleArn:AssociatedRole' :: AssociatedRole -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
associatedRoleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
certificateS3BucketName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
certificateS3ObjectKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
encryptionKmsKeyId