{-# 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.Lightsail.UntagResource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified set of tag keys and their values from the
-- specified Amazon Lightsail resource.
--
-- The @untag resource@ operation supports tag-based access control via
-- request tags and resource tags applied to the resource identified by
-- @resource name@. For more information, see the
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-controlling-access-using-tags Amazon Lightsail Developer Guide>.
module Amazonka.Lightsail.UntagResource
  ( -- * Creating a Request
    UntagResource (..),
    newUntagResource,

    -- * Request Lenses
    untagResource_resourceArn,
    untagResource_resourceName,
    untagResource_tagKeys,

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

    -- * Response Lenses
    untagResourceResponse_operations,
    untagResourceResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lightsail.Types
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 Amazon Resource Name (ARN) of the resource from which you want to
    -- remove a tag.
    UntagResource -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the resource from which you are removing a tag.
    UntagResource -> Text
resourceName :: Prelude.Text,
    -- | The tag keys to delete from the specified resource.
    UntagResource -> [Text]
tagKeys :: [Prelude.Text]
  }
  deriving (UntagResource -> UntagResource -> Bool
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]
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
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. 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:
--
-- 'resourceArn', 'untagResource_resourceArn' - The Amazon Resource Name (ARN) of the resource from which you want to
-- remove a tag.
--
-- 'resourceName', 'untagResource_resourceName' - The name of the resource from which you are removing a tag.
--
-- 'tagKeys', 'untagResource_tagKeys' - The tag keys to delete from the specified resource.
newUntagResource ::
  -- | 'resourceName'
  Prelude.Text ->
  UntagResource
newUntagResource :: Text -> UntagResource
newUntagResource Text
pResourceName_ =
  UntagResource'
    { $sel:resourceArn:UntagResource' :: Maybe Text
resourceArn = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceName:UntagResource' :: Text
resourceName = Text
pResourceName_,
      $sel:tagKeys:UntagResource' :: [Text]
tagKeys = forall a. Monoid a => a
Prelude.mempty
    }

-- | The Amazon Resource Name (ARN) of the resource from which you want to
-- remove a tag.
untagResource_resourceArn :: Lens.Lens' UntagResource (Prelude.Maybe Prelude.Text)
untagResource_resourceArn :: Lens' UntagResource (Maybe Text)
untagResource_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagResource' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:UntagResource' :: UntagResource -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: UntagResource
s@UntagResource' {} Maybe Text
a -> UntagResource
s {$sel:resourceArn:UntagResource' :: Maybe Text
resourceArn = Maybe Text
a} :: UntagResource)

-- | The name of the resource from which you are removing a tag.
untagResource_resourceName :: Lens.Lens' UntagResource Prelude.Text
untagResource_resourceName :: Lens' UntagResource Text
untagResource_resourceName = 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)

-- | The tag keys to delete from the specified resource.
untagResource_tagKeys :: Lens.Lens' UntagResource [Prelude.Text]
untagResource_tagKeys :: Lens' UntagResource [Text]
untagResource_tagKeys = 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) 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 UntagResource where
  type
    AWSResponse UntagResource =
      UntagResourceResponse
  request :: (Service -> Service) -> UntagResource -> Request UntagResource
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UntagResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UntagResource)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Operation] -> Int -> UntagResourceResponse
UntagResourceResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"operations" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UntagResource where
  hashWithSalt :: Int -> UntagResource -> Int
hashWithSalt Int
_salt UntagResource' {[Text]
Maybe Text
Text
tagKeys :: [Text]
resourceName :: Text
resourceArn :: Maybe Text
$sel:tagKeys:UntagResource' :: UntagResource -> [Text]
$sel:resourceName:UntagResource' :: UntagResource -> Text
$sel:resourceArn:UntagResource' :: UntagResource -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
tagKeys

instance Prelude.NFData UntagResource where
  rnf :: UntagResource -> ()
rnf UntagResource' {[Text]
Maybe Text
Text
tagKeys :: [Text]
resourceName :: Text
resourceArn :: Maybe Text
$sel:tagKeys:UntagResource' :: UntagResource -> [Text]
$sel:resourceName:UntagResource' :: UntagResource -> Text
$sel:resourceArn:UntagResource' :: UntagResource -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
tagKeys

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

instance Data.ToJSON UntagResource where
  toJSON :: UntagResource -> Value
toJSON UntagResource' {[Text]
Maybe Text
Text
tagKeys :: [Text]
resourceName :: Text
resourceArn :: Maybe Text
$sel:tagKeys:UntagResource' :: UntagResource -> [Text]
$sel:resourceName:UntagResource' :: UntagResource -> Text
$sel:resourceArn:UntagResource' :: UntagResource -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"resourceArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceArn,
            forall a. a -> Maybe a
Prelude.Just (Key
"resourceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceName),
            forall a. a -> Maybe a
Prelude.Just (Key
"tagKeys" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
tagKeys)
          ]
      )

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

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

-- | /See:/ 'newUntagResourceResponse' smart constructor.
data UntagResourceResponse = UntagResourceResponse'
  { -- | An array of objects that describe the result of the action, such as the
    -- status of the request, the timestamp of the request, and the resources
    -- affected by the request.
    UntagResourceResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
    -- | The response's http status code.
    UntagResourceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UntagResourceResponse -> UntagResourceResponse -> Bool
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]
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
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. 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:
--
-- 'operations', 'untagResourceResponse_operations' - An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
--
-- 'httpStatus', 'untagResourceResponse_httpStatus' - The response's http status code.
newUntagResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UntagResourceResponse
newUntagResourceResponse :: Int -> UntagResourceResponse
newUntagResourceResponse Int
pHttpStatus_ =
  UntagResourceResponse'
    { $sel:operations:UntagResourceResponse' :: Maybe [Operation]
operations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UntagResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
untagResourceResponse_operations :: Lens.Lens' UntagResourceResponse (Prelude.Maybe [Operation])
untagResourceResponse_operations :: Lens' UntagResourceResponse (Maybe [Operation])
untagResourceResponse_operations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagResourceResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:UntagResourceResponse' :: UntagResourceResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: UntagResourceResponse
s@UntagResourceResponse' {} Maybe [Operation]
a -> UntagResourceResponse
s {$sel:operations:UntagResourceResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: UntagResourceResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' UntagResourceResponse Int
untagResourceResponse_httpStatus = 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 where
  rnf :: UntagResourceResponse -> ()
rnf UntagResourceResponse' {Int
Maybe [Operation]
httpStatus :: Int
operations :: Maybe [Operation]
$sel:httpStatus:UntagResourceResponse' :: UntagResourceResponse -> Int
$sel:operations:UntagResourceResponse' :: UntagResourceResponse -> Maybe [Operation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Operation]
operations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus