{-# 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.CloudWatchLogs.UntagLogGroup
-- 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)
--
-- Removes the specified tags from the specified log group.
--
-- To list the tags for a log group, use
-- <https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_ListTagsLogGroup.html ListTagsLogGroup>.
-- To add tags, use
-- <https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_TagLogGroup.html TagLogGroup>.
--
-- CloudWatch Logs doesn’t support IAM policies that prevent users from
-- assigning specified tags to log groups using the
-- @aws:Resource\/key-name @ or @aws:TagKeys@ condition keys.
module Amazonka.CloudWatchLogs.UntagLogGroup
  ( -- * Creating a Request
    UntagLogGroup (..),
    newUntagLogGroup,

    -- * Request Lenses
    untagLogGroup_logGroupName,
    untagLogGroup_tags,

    -- * Destructuring the Response
    UntagLogGroupResponse (..),
    newUntagLogGroupResponse,
  )
where

import Amazonka.CloudWatchLogs.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

-- | /See:/ 'newUntagLogGroup' smart constructor.
data UntagLogGroup = UntagLogGroup'
  { -- | The name of the log group.
    UntagLogGroup -> Text
logGroupName :: Prelude.Text,
    -- | The tag keys. The corresponding tags are removed from the log group.
    UntagLogGroup -> NonEmpty Text
tags :: Prelude.NonEmpty Prelude.Text
  }
  deriving (UntagLogGroup -> UntagLogGroup -> Bool
(UntagLogGroup -> UntagLogGroup -> Bool)
-> (UntagLogGroup -> UntagLogGroup -> Bool) -> Eq UntagLogGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UntagLogGroup -> UntagLogGroup -> Bool
$c/= :: UntagLogGroup -> UntagLogGroup -> Bool
== :: UntagLogGroup -> UntagLogGroup -> Bool
$c== :: UntagLogGroup -> UntagLogGroup -> Bool
Prelude.Eq, ReadPrec [UntagLogGroup]
ReadPrec UntagLogGroup
Int -> ReadS UntagLogGroup
ReadS [UntagLogGroup]
(Int -> ReadS UntagLogGroup)
-> ReadS [UntagLogGroup]
-> ReadPrec UntagLogGroup
-> ReadPrec [UntagLogGroup]
-> Read UntagLogGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UntagLogGroup]
$creadListPrec :: ReadPrec [UntagLogGroup]
readPrec :: ReadPrec UntagLogGroup
$creadPrec :: ReadPrec UntagLogGroup
readList :: ReadS [UntagLogGroup]
$creadList :: ReadS [UntagLogGroup]
readsPrec :: Int -> ReadS UntagLogGroup
$creadsPrec :: Int -> ReadS UntagLogGroup
Prelude.Read, Int -> UntagLogGroup -> ShowS
[UntagLogGroup] -> ShowS
UntagLogGroup -> String
(Int -> UntagLogGroup -> ShowS)
-> (UntagLogGroup -> String)
-> ([UntagLogGroup] -> ShowS)
-> Show UntagLogGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UntagLogGroup] -> ShowS
$cshowList :: [UntagLogGroup] -> ShowS
show :: UntagLogGroup -> String
$cshow :: UntagLogGroup -> String
showsPrec :: Int -> UntagLogGroup -> ShowS
$cshowsPrec :: Int -> UntagLogGroup -> ShowS
Prelude.Show, (forall x. UntagLogGroup -> Rep UntagLogGroup x)
-> (forall x. Rep UntagLogGroup x -> UntagLogGroup)
-> Generic UntagLogGroup
forall x. Rep UntagLogGroup x -> UntagLogGroup
forall x. UntagLogGroup -> Rep UntagLogGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UntagLogGroup x -> UntagLogGroup
$cfrom :: forall x. UntagLogGroup -> Rep UntagLogGroup x
Prelude.Generic)

-- |
-- Create a value of 'UntagLogGroup' 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:
--
-- 'logGroupName', 'untagLogGroup_logGroupName' - The name of the log group.
--
-- 'tags', 'untagLogGroup_tags' - The tag keys. The corresponding tags are removed from the log group.
newUntagLogGroup ::
  -- | 'logGroupName'
  Prelude.Text ->
  -- | 'tags'
  Prelude.NonEmpty Prelude.Text ->
  UntagLogGroup
newUntagLogGroup :: Text -> NonEmpty Text -> UntagLogGroup
newUntagLogGroup Text
pLogGroupName_ NonEmpty Text
pTags_ =
  UntagLogGroup' :: Text -> NonEmpty Text -> UntagLogGroup
UntagLogGroup'
    { $sel:logGroupName:UntagLogGroup' :: Text
logGroupName = Text
pLogGroupName_,
      $sel:tags:UntagLogGroup' :: NonEmpty Text
tags = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pTags_
    }

-- | The name of the log group.
untagLogGroup_logGroupName :: Lens.Lens' UntagLogGroup Prelude.Text
untagLogGroup_logGroupName :: (Text -> f Text) -> UntagLogGroup -> f UntagLogGroup
untagLogGroup_logGroupName = (UntagLogGroup -> Text)
-> (UntagLogGroup -> Text -> UntagLogGroup)
-> Lens UntagLogGroup UntagLogGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagLogGroup' {Text
logGroupName :: Text
$sel:logGroupName:UntagLogGroup' :: UntagLogGroup -> Text
logGroupName} -> Text
logGroupName) (\s :: UntagLogGroup
s@UntagLogGroup' {} Text
a -> UntagLogGroup
s {$sel:logGroupName:UntagLogGroup' :: Text
logGroupName = Text
a} :: UntagLogGroup)

-- | The tag keys. The corresponding tags are removed from the log group.
untagLogGroup_tags :: Lens.Lens' UntagLogGroup (Prelude.NonEmpty Prelude.Text)
untagLogGroup_tags :: (NonEmpty Text -> f (NonEmpty Text))
-> UntagLogGroup -> f UntagLogGroup
untagLogGroup_tags = (UntagLogGroup -> NonEmpty Text)
-> (UntagLogGroup -> NonEmpty Text -> UntagLogGroup)
-> Lens UntagLogGroup UntagLogGroup (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagLogGroup' {NonEmpty Text
tags :: NonEmpty Text
$sel:tags:UntagLogGroup' :: UntagLogGroup -> NonEmpty Text
tags} -> NonEmpty Text
tags) (\s :: UntagLogGroup
s@UntagLogGroup' {} NonEmpty Text
a -> UntagLogGroup
s {$sel:tags:UntagLogGroup' :: NonEmpty Text
tags = NonEmpty Text
a} :: UntagLogGroup) ((NonEmpty Text -> f (NonEmpty Text))
 -> UntagLogGroup -> f UntagLogGroup)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> UntagLogGroup
-> f UntagLogGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable UntagLogGroup

instance Prelude.NFData UntagLogGroup

instance Core.ToHeaders UntagLogGroup where
  toHeaders :: UntagLogGroup -> [Header]
toHeaders =
    [Header] -> UntagLogGroup -> [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
"Logs_20140328.UntagLogGroup" ::
                          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 UntagLogGroup where
  toJSON :: UntagLogGroup -> Value
toJSON UntagLogGroup' {NonEmpty Text
Text
tags :: NonEmpty Text
logGroupName :: Text
$sel:tags:UntagLogGroup' :: UntagLogGroup -> NonEmpty Text
$sel:logGroupName:UntagLogGroup' :: UntagLogGroup -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"logGroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
logGroupName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"tags" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
tags)
          ]
      )

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

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

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

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

instance Prelude.NFData UntagLogGroupResponse