{-# 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.DAX.UntagResource
-- 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 association of tags from a DAX resource. You can call
-- @UntagResource@ up to 5 times per second, per account.
module Amazonka.DAX.UntagResource
  ( -- * Creating a Request
    UntagResource (..),
    newUntagResource,

    -- * Request Lenses
    untagResource_resourceName,
    untagResource_tagKeys,

    -- * Destructuring the Response
    UntagResourceResponse (..),
    newUntagResourceResponse,

    -- * Response Lenses
    untagResourceResponse_tags,
    untagResourceResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUntagResource' smart constructor.
data UntagResource = UntagResource'
  { -- | The name of the DAX resource from which the tags should be removed.
    UntagResource -> Text
resourceName :: Prelude.Text,
    -- | A list of tag keys. If the DAX cluster has any tags with these keys,
    -- then the tags are removed from the cluster.
    UntagResource -> [Text]
tagKeys :: [Prelude.Text]
  }
  deriving (UntagResource -> UntagResource -> Bool
(UntagResource -> UntagResource -> Bool)
-> (UntagResource -> UntagResource -> Bool) -> Eq UntagResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UntagResource -> UntagResource -> Bool
$c/= :: UntagResource -> UntagResource -> Bool
== :: UntagResource -> UntagResource -> Bool
$c== :: UntagResource -> UntagResource -> Bool
Prelude.Eq, ReadPrec [UntagResource]
ReadPrec UntagResource
Int -> ReadS UntagResource
ReadS [UntagResource]
(Int -> ReadS UntagResource)
-> ReadS [UntagResource]
-> ReadPrec UntagResource
-> ReadPrec [UntagResource]
-> Read UntagResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UntagResource]
$creadListPrec :: ReadPrec [UntagResource]
readPrec :: ReadPrec UntagResource
$creadPrec :: ReadPrec UntagResource
readList :: ReadS [UntagResource]
$creadList :: ReadS [UntagResource]
readsPrec :: Int -> ReadS UntagResource
$creadsPrec :: Int -> ReadS UntagResource
Prelude.Read, Int -> UntagResource -> ShowS
[UntagResource] -> ShowS
UntagResource -> String
(Int -> UntagResource -> ShowS)
-> (UntagResource -> String)
-> ([UntagResource] -> ShowS)
-> Show UntagResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UntagResource] -> ShowS
$cshowList :: [UntagResource] -> ShowS
show :: UntagResource -> String
$cshow :: UntagResource -> String
showsPrec :: Int -> UntagResource -> ShowS
$cshowsPrec :: Int -> UntagResource -> ShowS
Prelude.Show, (forall x. UntagResource -> Rep UntagResource x)
-> (forall x. Rep UntagResource x -> UntagResource)
-> Generic UntagResource
forall x. Rep UntagResource x -> UntagResource
forall x. UntagResource -> Rep UntagResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UntagResource x -> UntagResource
$cfrom :: forall x. UntagResource -> Rep UntagResource x
Prelude.Generic)

-- |
-- Create a value of 'UntagResource' 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:
--
-- 'resourceName', 'untagResource_resourceName' - The name of the DAX resource from which the tags should be removed.
--
-- 'tagKeys', 'untagResource_tagKeys' - A list of tag keys. If the DAX cluster has any tags with these keys,
-- then the tags are removed from the cluster.
newUntagResource ::
  -- | 'resourceName'
  Prelude.Text ->
  UntagResource
newUntagResource :: Text -> UntagResource
newUntagResource Text
pResourceName_ =
  UntagResource' :: Text -> [Text] -> UntagResource
UntagResource'
    { $sel:resourceName:UntagResource' :: Text
resourceName = Text
pResourceName_,
      $sel:tagKeys:UntagResource' :: [Text]
tagKeys = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of the DAX resource from which the tags should be removed.
untagResource_resourceName :: Lens.Lens' UntagResource Prelude.Text
untagResource_resourceName :: (Text -> f Text) -> UntagResource -> f UntagResource
untagResource_resourceName = (UntagResource -> Text)
-> (UntagResource -> Text -> UntagResource)
-> Lens UntagResource UntagResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagResource' {Text
resourceName :: Text
$sel:resourceName:UntagResource' :: UntagResource -> Text
resourceName} -> Text
resourceName) (\s :: UntagResource
s@UntagResource' {} Text
a -> UntagResource
s {$sel:resourceName:UntagResource' :: Text
resourceName = Text
a} :: UntagResource)

-- | A list of tag keys. If the DAX cluster has any tags with these keys,
-- then the tags are removed from the cluster.
untagResource_tagKeys :: Lens.Lens' UntagResource [Prelude.Text]
untagResource_tagKeys :: ([Text] -> f [Text]) -> UntagResource -> f UntagResource
untagResource_tagKeys = (UntagResource -> [Text])
-> (UntagResource -> [Text] -> UntagResource)
-> Lens UntagResource UntagResource [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagResource' {[Text]
tagKeys :: [Text]
$sel:tagKeys:UntagResource' :: UntagResource -> [Text]
tagKeys} -> [Text]
tagKeys) (\s :: UntagResource
s@UntagResource' {} [Text]
a -> UntagResource
s {$sel:tagKeys:UntagResource' :: [Text]
tagKeys = [Text]
a} :: UntagResource) (([Text] -> f [Text]) -> UntagResource -> f UntagResource)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> UntagResource
-> f UntagResource
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 UntagResource where
  type
    AWSResponse UntagResource =
      UntagResourceResponse
  request :: UntagResource -> Request UntagResource
request = Service -> UntagResource -> Request UntagResource
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UntagResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UntagResource)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UntagResource))
-> Logger
-> Service
-> Proxy UntagResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UntagResource)))
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 [Tag] -> Int -> UntagResourceResponse
UntagResourceResponse'
            (Maybe [Tag] -> Int -> UntagResourceResponse)
-> Either String (Maybe [Tag])
-> Either String (Int -> UntagResourceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Tag]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Tags" Either String (Maybe (Maybe [Tag]))
-> Maybe [Tag] -> Either String (Maybe [Tag])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Tag]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> UntagResourceResponse)
-> Either String Int -> Either String UntagResourceResponse
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 UntagResource

instance Prelude.NFData UntagResource

instance Core.ToHeaders UntagResource where
  toHeaders :: UntagResource -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UntagResource -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"AmazonDAXV3.UntagResource" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UntagResource where
  toJSON :: UntagResource -> Value
toJSON UntagResource' {[Text]
Text
tagKeys :: [Text]
resourceName :: Text
$sel:tagKeys:UntagResource' :: UntagResource -> [Text]
$sel:resourceName:UntagResource' :: UntagResource -> 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
"ResourceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TagKeys" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
tagKeys)
          ]
      )

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

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

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

-- |
-- Create a value of 'UntagResourceResponse' 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:
--
-- 'tags', 'untagResourceResponse_tags' - The tag keys that have been removed from the cluster.
--
-- 'httpStatus', 'untagResourceResponse_httpStatus' - The response's http status code.
newUntagResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UntagResourceResponse
newUntagResourceResponse :: Int -> UntagResourceResponse
newUntagResourceResponse Int
pHttpStatus_ =
  UntagResourceResponse' :: Maybe [Tag] -> Int -> UntagResourceResponse
UntagResourceResponse'
    { $sel:tags:UntagResourceResponse' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UntagResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The tag keys that have been removed from the cluster.
untagResourceResponse_tags :: Lens.Lens' UntagResourceResponse (Prelude.Maybe [Tag])
untagResourceResponse_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> UntagResourceResponse -> f UntagResourceResponse
untagResourceResponse_tags = (UntagResourceResponse -> Maybe [Tag])
-> (UntagResourceResponse -> Maybe [Tag] -> UntagResourceResponse)
-> Lens
     UntagResourceResponse
     UntagResourceResponse
     (Maybe [Tag])
     (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagResourceResponse' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:UntagResourceResponse' :: UntagResourceResponse -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: UntagResourceResponse
s@UntagResourceResponse' {} Maybe [Tag]
a -> UntagResourceResponse
s {$sel:tags:UntagResourceResponse' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: UntagResourceResponse) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> UntagResourceResponse -> f UntagResourceResponse)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> UntagResourceResponse
-> f UntagResourceResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData UntagResourceResponse