{-# 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.ResourceGroups.Untag
-- 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)
--
-- Deletes tags from a specified resource group.
--
-- __Minimum permissions__
--
-- To run this command, you must have the following permissions:
--
-- -   @resource-groups:Untag@
module Amazonka.ResourceGroups.Untag
  ( -- * Creating a Request
    Untag (..),
    newUntag,

    -- * Request Lenses
    untag_arn,
    untag_keys,

    -- * Destructuring the Response
    UntagResponse (..),
    newUntagResponse,

    -- * Response Lenses
    untagResponse_arn,
    untagResponse_keys,
    untagResponse_httpStatus,
  )
where

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 Amazonka.ResourceGroups.Types
import qualified Amazonka.Response as Response

-- | /See:/ 'newUntag' smart constructor.
data Untag = Untag'
  { -- | The ARN of the resource group from which to remove tags. The command
    -- removed both the specified keys and any values associated with those
    -- keys.
    Untag -> Text
arn :: Prelude.Text,
    -- | The keys of the tags to be removed.
    Untag -> [Text]
keys :: [Prelude.Text]
  }
  deriving (Untag -> Untag -> Bool
(Untag -> Untag -> Bool) -> (Untag -> Untag -> Bool) -> Eq Untag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Untag -> Untag -> Bool
$c/= :: Untag -> Untag -> Bool
== :: Untag -> Untag -> Bool
$c== :: Untag -> Untag -> Bool
Prelude.Eq, ReadPrec [Untag]
ReadPrec Untag
Int -> ReadS Untag
ReadS [Untag]
(Int -> ReadS Untag)
-> ReadS [Untag]
-> ReadPrec Untag
-> ReadPrec [Untag]
-> Read Untag
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Untag]
$creadListPrec :: ReadPrec [Untag]
readPrec :: ReadPrec Untag
$creadPrec :: ReadPrec Untag
readList :: ReadS [Untag]
$creadList :: ReadS [Untag]
readsPrec :: Int -> ReadS Untag
$creadsPrec :: Int -> ReadS Untag
Prelude.Read, Int -> Untag -> ShowS
[Untag] -> ShowS
Untag -> String
(Int -> Untag -> ShowS)
-> (Untag -> String) -> ([Untag] -> ShowS) -> Show Untag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Untag] -> ShowS
$cshowList :: [Untag] -> ShowS
show :: Untag -> String
$cshow :: Untag -> String
showsPrec :: Int -> Untag -> ShowS
$cshowsPrec :: Int -> Untag -> ShowS
Prelude.Show, (forall x. Untag -> Rep Untag x)
-> (forall x. Rep Untag x -> Untag) -> Generic Untag
forall x. Rep Untag x -> Untag
forall x. Untag -> Rep Untag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Untag x -> Untag
$cfrom :: forall x. Untag -> Rep Untag x
Prelude.Generic)

-- |
-- Create a value of 'Untag' 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:
--
-- 'arn', 'untag_arn' - The ARN of the resource group from which to remove tags. The command
-- removed both the specified keys and any values associated with those
-- keys.
--
-- 'keys', 'untag_keys' - The keys of the tags to be removed.
newUntag ::
  -- | 'arn'
  Prelude.Text ->
  Untag
newUntag :: Text -> Untag
newUntag Text
pArn_ =
  Untag' :: Text -> [Text] -> Untag
Untag' {$sel:arn:Untag' :: Text
arn = Text
pArn_, $sel:keys:Untag' :: [Text]
keys = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | The ARN of the resource group from which to remove tags. The command
-- removed both the specified keys and any values associated with those
-- keys.
untag_arn :: Lens.Lens' Untag Prelude.Text
untag_arn :: (Text -> f Text) -> Untag -> f Untag
untag_arn = (Untag -> Text)
-> (Untag -> Text -> Untag) -> Lens Untag Untag Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Untag' {Text
arn :: Text
$sel:arn:Untag' :: Untag -> Text
arn} -> Text
arn) (\s :: Untag
s@Untag' {} Text
a -> Untag
s {$sel:arn:Untag' :: Text
arn = Text
a} :: Untag)

-- | The keys of the tags to be removed.
untag_keys :: Lens.Lens' Untag [Prelude.Text]
untag_keys :: ([Text] -> f [Text]) -> Untag -> f Untag
untag_keys = (Untag -> [Text])
-> (Untag -> [Text] -> Untag) -> Lens Untag Untag [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Untag' {[Text]
keys :: [Text]
$sel:keys:Untag' :: Untag -> [Text]
keys} -> [Text]
keys) (\s :: Untag
s@Untag' {} [Text]
a -> Untag
s {$sel:keys:Untag' :: [Text]
keys = [Text]
a} :: Untag) (([Text] -> f [Text]) -> Untag -> f Untag)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> Untag
-> f Untag
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest Untag where
  type AWSResponse Untag = UntagResponse
  request :: Untag -> Request Untag
request = Service -> Untag -> Request Untag
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy Untag
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Untag)))
response =
    (Int
 -> ResponseHeaders -> Object -> Either String (AWSResponse Untag))
-> Logger
-> Service
-> Proxy Untag
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Untag)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Maybe [Text] -> Int -> UntagResponse
UntagResponse'
            (Maybe Text -> Maybe [Text] -> Int -> UntagResponse)
-> Either String (Maybe Text)
-> Either String (Maybe [Text] -> Int -> UntagResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Arn")
            Either String (Maybe [Text] -> Int -> UntagResponse)
-> Either String (Maybe [Text])
-> Either String (Int -> UntagResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Keys" Either String (Maybe (Maybe [Text]))
-> Maybe [Text] -> Either String (Maybe [Text])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> UntagResponse)
-> Either String Int -> Either String UntagResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable Untag

instance Prelude.NFData Untag

instance Core.ToHeaders Untag where
  toHeaders :: Untag -> ResponseHeaders
toHeaders = ResponseHeaders -> Untag -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON Untag where
  toJSON :: Untag -> Value
toJSON Untag' {[Text]
Text
keys :: [Text]
arn :: Text
$sel:keys:Untag' :: Untag -> [Text]
$sel:arn:Untag' :: Untag -> 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
"Keys" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
keys)]
      )

instance Core.ToPath Untag where
  toPath :: Untag -> ByteString
toPath Untag' {[Text]
Text
keys :: [Text]
arn :: Text
$sel:keys:Untag' :: Untag -> [Text]
$sel:arn:Untag' :: Untag -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/resources/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
arn, ByteString
"/tags"]

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

-- | /See:/ 'newUntagResponse' smart constructor.
data UntagResponse = UntagResponse'
  { -- | The ARN of the resource group from which tags have been removed.
    UntagResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The keys of the tags that were removed.
    UntagResponse -> Maybe [Text]
keys :: Prelude.Maybe [Prelude.Text],
    -- | The response's http status code.
    UntagResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UntagResponse -> UntagResponse -> Bool
(UntagResponse -> UntagResponse -> Bool)
-> (UntagResponse -> UntagResponse -> Bool) -> Eq UntagResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UntagResponse -> UntagResponse -> Bool
$c/= :: UntagResponse -> UntagResponse -> Bool
== :: UntagResponse -> UntagResponse -> Bool
$c== :: UntagResponse -> UntagResponse -> Bool
Prelude.Eq, ReadPrec [UntagResponse]
ReadPrec UntagResponse
Int -> ReadS UntagResponse
ReadS [UntagResponse]
(Int -> ReadS UntagResponse)
-> ReadS [UntagResponse]
-> ReadPrec UntagResponse
-> ReadPrec [UntagResponse]
-> Read UntagResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UntagResponse]
$creadListPrec :: ReadPrec [UntagResponse]
readPrec :: ReadPrec UntagResponse
$creadPrec :: ReadPrec UntagResponse
readList :: ReadS [UntagResponse]
$creadList :: ReadS [UntagResponse]
readsPrec :: Int -> ReadS UntagResponse
$creadsPrec :: Int -> ReadS UntagResponse
Prelude.Read, Int -> UntagResponse -> ShowS
[UntagResponse] -> ShowS
UntagResponse -> String
(Int -> UntagResponse -> ShowS)
-> (UntagResponse -> String)
-> ([UntagResponse] -> ShowS)
-> Show UntagResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UntagResponse] -> ShowS
$cshowList :: [UntagResponse] -> ShowS
show :: UntagResponse -> String
$cshow :: UntagResponse -> String
showsPrec :: Int -> UntagResponse -> ShowS
$cshowsPrec :: Int -> UntagResponse -> ShowS
Prelude.Show, (forall x. UntagResponse -> Rep UntagResponse x)
-> (forall x. Rep UntagResponse x -> UntagResponse)
-> Generic UntagResponse
forall x. Rep UntagResponse x -> UntagResponse
forall x. UntagResponse -> Rep UntagResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UntagResponse x -> UntagResponse
$cfrom :: forall x. UntagResponse -> Rep UntagResponse x
Prelude.Generic)

-- |
-- Create a value of 'UntagResponse' 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:
--
-- 'arn', 'untagResponse_arn' - The ARN of the resource group from which tags have been removed.
--
-- 'keys', 'untagResponse_keys' - The keys of the tags that were removed.
--
-- 'httpStatus', 'untagResponse_httpStatus' - The response's http status code.
newUntagResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UntagResponse
newUntagResponse :: Int -> UntagResponse
newUntagResponse Int
pHttpStatus_ =
  UntagResponse' :: Maybe Text -> Maybe [Text] -> Int -> UntagResponse
UntagResponse'
    { $sel:arn:UntagResponse' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:keys:UntagResponse' :: Maybe [Text]
keys = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UntagResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the resource group from which tags have been removed.
untagResponse_arn :: Lens.Lens' UntagResponse (Prelude.Maybe Prelude.Text)
untagResponse_arn :: (Maybe Text -> f (Maybe Text)) -> UntagResponse -> f UntagResponse
untagResponse_arn = (UntagResponse -> Maybe Text)
-> (UntagResponse -> Maybe Text -> UntagResponse)
-> Lens UntagResponse UntagResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:UntagResponse' :: UntagResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: UntagResponse
s@UntagResponse' {} Maybe Text
a -> UntagResponse
s {$sel:arn:UntagResponse' :: Maybe Text
arn = Maybe Text
a} :: UntagResponse)

-- | The keys of the tags that were removed.
untagResponse_keys :: Lens.Lens' UntagResponse (Prelude.Maybe [Prelude.Text])
untagResponse_keys :: (Maybe [Text] -> f (Maybe [Text]))
-> UntagResponse -> f UntagResponse
untagResponse_keys = (UntagResponse -> Maybe [Text])
-> (UntagResponse -> Maybe [Text] -> UntagResponse)
-> Lens UntagResponse UntagResponse (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagResponse' {Maybe [Text]
keys :: Maybe [Text]
$sel:keys:UntagResponse' :: UntagResponse -> Maybe [Text]
keys} -> Maybe [Text]
keys) (\s :: UntagResponse
s@UntagResponse' {} Maybe [Text]
a -> UntagResponse
s {$sel:keys:UntagResponse' :: Maybe [Text]
keys = Maybe [Text]
a} :: UntagResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> UntagResponse -> f UntagResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> UntagResponse
-> f UntagResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
untagResponse_httpStatus :: Lens.Lens' UntagResponse Prelude.Int
untagResponse_httpStatus :: (Int -> f Int) -> UntagResponse -> f UntagResponse
untagResponse_httpStatus = (UntagResponse -> Int)
-> (UntagResponse -> Int -> UntagResponse)
-> Lens UntagResponse UntagResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagResponse' {Int
httpStatus :: Int
$sel:httpStatus:UntagResponse' :: UntagResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UntagResponse
s@UntagResponse' {} Int
a -> UntagResponse
s {$sel:httpStatus:UntagResponse' :: Int
httpStatus = Int
a} :: UntagResponse)

instance Prelude.NFData UntagResponse