amazonka-lightsail-2.0: gen/Amazonka/Lightsail/UntagResource.hs
{-# 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.
resourceArn :: Prelude.Maybe Prelude.Text,
-- | The name of the resource from which you are removing a tag.
resourceName :: Prelude.Text,
-- | The tag keys to delete from the specified resource.
tagKeys :: [Prelude.Text]
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, 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 pResourceName_ =
UntagResource'
{ resourceArn = Prelude.Nothing,
resourceName = pResourceName_,
tagKeys = 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.lens (\UntagResource' {resourceArn} -> resourceArn) (\s@UntagResource' {} a -> s {resourceArn = a} :: UntagResource)
-- | The name of the resource from which you are removing a tag.
untagResource_resourceName :: Lens.Lens' UntagResource Prelude.Text
untagResource_resourceName = Lens.lens (\UntagResource' {resourceName} -> resourceName) (\s@UntagResource' {} a -> s {resourceName = a} :: UntagResource)
-- | The tag keys to delete from the specified resource.
untagResource_tagKeys :: Lens.Lens' UntagResource [Prelude.Text]
untagResource_tagKeys = Lens.lens (\UntagResource' {tagKeys} -> tagKeys) (\s@UntagResource' {} a -> s {tagKeys = a} :: UntagResource) Prelude.. Lens.coerced
instance Core.AWSRequest UntagResource where
type
AWSResponse UntagResource =
UntagResourceResponse
request overrides =
Request.postJSON (overrides defaultService)
response =
Response.receiveJSON
( \s h x ->
UntagResourceResponse'
Prelude.<$> (x Data..?> "operations" Core..!@ Prelude.mempty)
Prelude.<*> (Prelude.pure (Prelude.fromEnum s))
)
instance Prelude.Hashable UntagResource where
hashWithSalt _salt UntagResource' {..} =
_salt
`Prelude.hashWithSalt` resourceArn
`Prelude.hashWithSalt` resourceName
`Prelude.hashWithSalt` tagKeys
instance Prelude.NFData UntagResource where
rnf UntagResource' {..} =
Prelude.rnf resourceArn
`Prelude.seq` Prelude.rnf resourceName
`Prelude.seq` Prelude.rnf tagKeys
instance Data.ToHeaders UntagResource where
toHeaders =
Prelude.const
( Prelude.mconcat
[ "X-Amz-Target"
Data.=# ( "Lightsail_20161128.UntagResource" ::
Prelude.ByteString
),
"Content-Type"
Data.=# ( "application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON UntagResource where
toJSON UntagResource' {..} =
Data.object
( Prelude.catMaybes
[ ("resourceArn" Data..=) Prelude.<$> resourceArn,
Prelude.Just ("resourceName" Data..= resourceName),
Prelude.Just ("tagKeys" Data..= tagKeys)
]
)
instance Data.ToPath UntagResource where
toPath = Prelude.const "/"
instance Data.ToQuery UntagResource where
toQuery = Prelude.const 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.
operations :: Prelude.Maybe [Operation],
-- | The response's http status code.
httpStatus :: Prelude.Int
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, 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 pHttpStatus_ =
UntagResourceResponse'
{ operations =
Prelude.Nothing,
httpStatus = 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.lens (\UntagResourceResponse' {operations} -> operations) (\s@UntagResourceResponse' {} a -> s {operations = a} :: UntagResourceResponse) Prelude.. Lens.mapping Lens.coerced
-- | The response's http status code.
untagResourceResponse_httpStatus :: Lens.Lens' UntagResourceResponse Prelude.Int
untagResourceResponse_httpStatus = Lens.lens (\UntagResourceResponse' {httpStatus} -> httpStatus) (\s@UntagResourceResponse' {} a -> s {httpStatus = a} :: UntagResourceResponse)
instance Prelude.NFData UntagResourceResponse where
rnf UntagResourceResponse' {..} =
Prelude.rnf operations
`Prelude.seq` Prelude.rnf httpStatus