{-# 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.IAM.TagMFADevice
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Adds one or more tags to an IAM virtual multi-factor authentication
-- (MFA) device. If a tag with the same key name already exists, then that
-- tag is overwritten with the new value.
--
-- A tag consists of a key name and an associated value. By assigning tags
-- to your resources, you can do the following:
--
-- -   __Administrative grouping and discovery__ - Attach tags to resources
--     to aid in organization and search. For example, you could search for
--     all resources with the key name /Project/ and the value
--     /MyImportantProject/. Or search for all resources with the key name
--     /Cost Center/ and the value /41200/.
--
-- -   __Access control__ - Include tags in IAM user-based and
--     resource-based policies. You can use tags to restrict access to only
--     an IAM virtual MFA device that has a specified tag attached. For
--     examples of policies that show how to use tags to control access,
--     see
--     <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_tags.html Control access using IAM tags>
--     in the /IAM User Guide/.
--
-- -   If any one of the tags is invalid or if you exceed the allowed
--     maximum number of tags, then the entire request fails and the
--     resource is not created. For more information about tagging, see
--     <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
--     in the /IAM User Guide/.
--
-- -   Amazon Web Services always interprets the tag @Value@ as a single
--     string. If you need to store an array, you can store comma-separated
--     values in the string. However, you must interpret the value in your
--     code.
module Amazonka.IAM.TagMFADevice
  ( -- * Creating a Request
    TagMFADevice (..),
    newTagMFADevice,

    -- * Request Lenses
    tagMFADevice_serialNumber,
    tagMFADevice_tags,

    -- * Destructuring the Response
    TagMFADeviceResponse (..),
    newTagMFADeviceResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IAM.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newTagMFADevice' smart constructor.
data TagMFADevice = TagMFADevice'
  { -- | The unique identifier for the IAM virtual MFA device to which you want
    -- to add tags. For virtual MFA devices, the serial number is the same as
    -- the ARN.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of upper and lowercase alphanumeric characters with no
    -- spaces. You can also include any of the following characters: _+=,.\@-
    TagMFADevice -> Text
serialNumber :: Prelude.Text,
    -- | The list of tags that you want to attach to the IAM virtual MFA device.
    -- Each tag consists of a key name and an associated value.
    TagMFADevice -> [Tag]
tags :: [Tag]
  }
  deriving (TagMFADevice -> TagMFADevice -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagMFADevice -> TagMFADevice -> Bool
$c/= :: TagMFADevice -> TagMFADevice -> Bool
== :: TagMFADevice -> TagMFADevice -> Bool
$c== :: TagMFADevice -> TagMFADevice -> Bool
Prelude.Eq, ReadPrec [TagMFADevice]
ReadPrec TagMFADevice
Int -> ReadS TagMFADevice
ReadS [TagMFADevice]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagMFADevice]
$creadListPrec :: ReadPrec [TagMFADevice]
readPrec :: ReadPrec TagMFADevice
$creadPrec :: ReadPrec TagMFADevice
readList :: ReadS [TagMFADevice]
$creadList :: ReadS [TagMFADevice]
readsPrec :: Int -> ReadS TagMFADevice
$creadsPrec :: Int -> ReadS TagMFADevice
Prelude.Read, Int -> TagMFADevice -> ShowS
[TagMFADevice] -> ShowS
TagMFADevice -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagMFADevice] -> ShowS
$cshowList :: [TagMFADevice] -> ShowS
show :: TagMFADevice -> String
$cshow :: TagMFADevice -> String
showsPrec :: Int -> TagMFADevice -> ShowS
$cshowsPrec :: Int -> TagMFADevice -> ShowS
Prelude.Show, forall x. Rep TagMFADevice x -> TagMFADevice
forall x. TagMFADevice -> Rep TagMFADevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagMFADevice x -> TagMFADevice
$cfrom :: forall x. TagMFADevice -> Rep TagMFADevice x
Prelude.Generic)

-- |
-- Create a value of 'TagMFADevice' 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:
--
-- 'serialNumber', 'tagMFADevice_serialNumber' - The unique identifier for the IAM virtual MFA device to which you want
-- to add tags. For virtual MFA devices, the serial number is the same as
-- the ARN.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
--
-- 'tags', 'tagMFADevice_tags' - The list of tags that you want to attach to the IAM virtual MFA device.
-- Each tag consists of a key name and an associated value.
newTagMFADevice ::
  -- | 'serialNumber'
  Prelude.Text ->
  TagMFADevice
newTagMFADevice :: Text -> TagMFADevice
newTagMFADevice Text
pSerialNumber_ =
  TagMFADevice'
    { $sel:serialNumber:TagMFADevice' :: Text
serialNumber = Text
pSerialNumber_,
      $sel:tags:TagMFADevice' :: [Tag]
tags = forall a. Monoid a => a
Prelude.mempty
    }

-- | The unique identifier for the IAM virtual MFA device to which you want
-- to add tags. For virtual MFA devices, the serial number is the same as
-- the ARN.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
tagMFADevice_serialNumber :: Lens.Lens' TagMFADevice Prelude.Text
tagMFADevice_serialNumber :: Lens' TagMFADevice Text
tagMFADevice_serialNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagMFADevice' {Text
serialNumber :: Text
$sel:serialNumber:TagMFADevice' :: TagMFADevice -> Text
serialNumber} -> Text
serialNumber) (\s :: TagMFADevice
s@TagMFADevice' {} Text
a -> TagMFADevice
s {$sel:serialNumber:TagMFADevice' :: Text
serialNumber = Text
a} :: TagMFADevice)

-- | The list of tags that you want to attach to the IAM virtual MFA device.
-- Each tag consists of a key name and an associated value.
tagMFADevice_tags :: Lens.Lens' TagMFADevice [Tag]
tagMFADevice_tags :: Lens' TagMFADevice [Tag]
tagMFADevice_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagMFADevice' {[Tag]
tags :: [Tag]
$sel:tags:TagMFADevice' :: TagMFADevice -> [Tag]
tags} -> [Tag]
tags) (\s :: TagMFADevice
s@TagMFADevice' {} [Tag]
a -> TagMFADevice
s {$sel:tags:TagMFADevice' :: [Tag]
tags = [Tag]
a} :: TagMFADevice) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable TagMFADevice where
  hashWithSalt :: Int -> TagMFADevice -> Int
hashWithSalt Int
_salt TagMFADevice' {[Tag]
Text
tags :: [Tag]
serialNumber :: Text
$sel:tags:TagMFADevice' :: TagMFADevice -> [Tag]
$sel:serialNumber:TagMFADevice' :: TagMFADevice -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
serialNumber
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Tag]
tags

instance Prelude.NFData TagMFADevice where
  rnf :: TagMFADevice -> ()
rnf TagMFADevice' {[Tag]
Text
tags :: [Tag]
serialNumber :: Text
$sel:tags:TagMFADevice' :: TagMFADevice -> [Tag]
$sel:serialNumber:TagMFADevice' :: TagMFADevice -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
serialNumber
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Tag]
tags

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

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

instance Data.ToQuery TagMFADevice where
  toQuery :: TagMFADevice -> QueryString
toQuery TagMFADevice' {[Tag]
Text
tags :: [Tag]
serialNumber :: Text
$sel:tags:TagMFADevice' :: TagMFADevice -> [Tag]
$sel:serialNumber:TagMFADevice' :: TagMFADevice -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"TagMFADevice" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"SerialNumber" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
serialNumber,
        ByteString
"Tags" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" [Tag]
tags
      ]

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

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

instance Prelude.NFData TagMFADeviceResponse where
  rnf :: TagMFADeviceResponse -> ()
rnf TagMFADeviceResponse
_ = ()