{-# 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.MachineLearning.DeleteTags
-- 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 the specified tags associated with an ML object. After this
-- operation is complete, you can\'t recover deleted tags.
--
-- If you specify a tag that doesn\'t exist, Amazon ML ignores it.
module Amazonka.MachineLearning.DeleteTags
  ( -- * Creating a Request
    DeleteTags (..),
    newDeleteTags,

    -- * Request Lenses
    deleteTags_tagKeys,
    deleteTags_resourceId,
    deleteTags_resourceType,

    -- * Destructuring the Response
    DeleteTagsResponse (..),
    newDeleteTagsResponse,

    -- * Response Lenses
    deleteTagsResponse_resourceId,
    deleteTagsResponse_resourceType,
    deleteTagsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MachineLearning.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteTags' smart constructor.
data DeleteTags = DeleteTags'
  { -- | One or more tags to delete.
    DeleteTags -> [Text]
tagKeys :: [Prelude.Text],
    -- | The ID of the tagged ML object. For example, @exampleModelId@.
    DeleteTags -> Text
resourceId :: Prelude.Text,
    -- | The type of the tagged ML object.
    DeleteTags -> TaggableResourceType
resourceType :: TaggableResourceType
  }
  deriving (DeleteTags -> DeleteTags -> Bool
(DeleteTags -> DeleteTags -> Bool)
-> (DeleteTags -> DeleteTags -> Bool) -> Eq DeleteTags
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteTags -> DeleteTags -> Bool
$c/= :: DeleteTags -> DeleteTags -> Bool
== :: DeleteTags -> DeleteTags -> Bool
$c== :: DeleteTags -> DeleteTags -> Bool
Prelude.Eq, ReadPrec [DeleteTags]
ReadPrec DeleteTags
Int -> ReadS DeleteTags
ReadS [DeleteTags]
(Int -> ReadS DeleteTags)
-> ReadS [DeleteTags]
-> ReadPrec DeleteTags
-> ReadPrec [DeleteTags]
-> Read DeleteTags
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteTags]
$creadListPrec :: ReadPrec [DeleteTags]
readPrec :: ReadPrec DeleteTags
$creadPrec :: ReadPrec DeleteTags
readList :: ReadS [DeleteTags]
$creadList :: ReadS [DeleteTags]
readsPrec :: Int -> ReadS DeleteTags
$creadsPrec :: Int -> ReadS DeleteTags
Prelude.Read, Int -> DeleteTags -> ShowS
[DeleteTags] -> ShowS
DeleteTags -> String
(Int -> DeleteTags -> ShowS)
-> (DeleteTags -> String)
-> ([DeleteTags] -> ShowS)
-> Show DeleteTags
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteTags] -> ShowS
$cshowList :: [DeleteTags] -> ShowS
show :: DeleteTags -> String
$cshow :: DeleteTags -> String
showsPrec :: Int -> DeleteTags -> ShowS
$cshowsPrec :: Int -> DeleteTags -> ShowS
Prelude.Show, (forall x. DeleteTags -> Rep DeleteTags x)
-> (forall x. Rep DeleteTags x -> DeleteTags) -> Generic DeleteTags
forall x. Rep DeleteTags x -> DeleteTags
forall x. DeleteTags -> Rep DeleteTags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteTags x -> DeleteTags
$cfrom :: forall x. DeleteTags -> Rep DeleteTags x
Prelude.Generic)

-- |
-- Create a value of 'DeleteTags' 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:
--
-- 'tagKeys', 'deleteTags_tagKeys' - One or more tags to delete.
--
-- 'resourceId', 'deleteTags_resourceId' - The ID of the tagged ML object. For example, @exampleModelId@.
--
-- 'resourceType', 'deleteTags_resourceType' - The type of the tagged ML object.
newDeleteTags ::
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'resourceType'
  TaggableResourceType ->
  DeleteTags
newDeleteTags :: Text -> TaggableResourceType -> DeleteTags
newDeleteTags Text
pResourceId_ TaggableResourceType
pResourceType_ =
  DeleteTags' :: [Text] -> Text -> TaggableResourceType -> DeleteTags
DeleteTags'
    { $sel:tagKeys:DeleteTags' :: [Text]
tagKeys = [Text]
forall a. Monoid a => a
Prelude.mempty,
      $sel:resourceId:DeleteTags' :: Text
resourceId = Text
pResourceId_,
      $sel:resourceType:DeleteTags' :: TaggableResourceType
resourceType = TaggableResourceType
pResourceType_
    }

-- | One or more tags to delete.
deleteTags_tagKeys :: Lens.Lens' DeleteTags [Prelude.Text]
deleteTags_tagKeys :: ([Text] -> f [Text]) -> DeleteTags -> f DeleteTags
deleteTags_tagKeys = (DeleteTags -> [Text])
-> (DeleteTags -> [Text] -> DeleteTags)
-> Lens DeleteTags DeleteTags [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTags' {[Text]
tagKeys :: [Text]
$sel:tagKeys:DeleteTags' :: DeleteTags -> [Text]
tagKeys} -> [Text]
tagKeys) (\s :: DeleteTags
s@DeleteTags' {} [Text]
a -> DeleteTags
s {$sel:tagKeys:DeleteTags' :: [Text]
tagKeys = [Text]
a} :: DeleteTags) (([Text] -> f [Text]) -> DeleteTags -> f DeleteTags)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DeleteTags
-> f DeleteTags
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

-- | The ID of the tagged ML object. For example, @exampleModelId@.
deleteTags_resourceId :: Lens.Lens' DeleteTags Prelude.Text
deleteTags_resourceId :: (Text -> f Text) -> DeleteTags -> f DeleteTags
deleteTags_resourceId = (DeleteTags -> Text)
-> (DeleteTags -> Text -> DeleteTags)
-> Lens DeleteTags DeleteTags Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTags' {Text
resourceId :: Text
$sel:resourceId:DeleteTags' :: DeleteTags -> Text
resourceId} -> Text
resourceId) (\s :: DeleteTags
s@DeleteTags' {} Text
a -> DeleteTags
s {$sel:resourceId:DeleteTags' :: Text
resourceId = Text
a} :: DeleteTags)

-- | The type of the tagged ML object.
deleteTags_resourceType :: Lens.Lens' DeleteTags TaggableResourceType
deleteTags_resourceType :: (TaggableResourceType -> f TaggableResourceType)
-> DeleteTags -> f DeleteTags
deleteTags_resourceType = (DeleteTags -> TaggableResourceType)
-> (DeleteTags -> TaggableResourceType -> DeleteTags)
-> Lens
     DeleteTags DeleteTags TaggableResourceType TaggableResourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTags' {TaggableResourceType
resourceType :: TaggableResourceType
$sel:resourceType:DeleteTags' :: DeleteTags -> TaggableResourceType
resourceType} -> TaggableResourceType
resourceType) (\s :: DeleteTags
s@DeleteTags' {} TaggableResourceType
a -> DeleteTags
s {$sel:resourceType:DeleteTags' :: TaggableResourceType
resourceType = TaggableResourceType
a} :: DeleteTags)

instance Core.AWSRequest DeleteTags where
  type AWSResponse DeleteTags = DeleteTagsResponse
  request :: DeleteTags -> Request DeleteTags
request = Service -> DeleteTags -> Request DeleteTags
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteTags)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteTags))
-> Logger
-> Service
-> Proxy DeleteTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteTags)))
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 TaggableResourceType -> Int -> DeleteTagsResponse
DeleteTagsResponse'
            (Maybe Text
 -> Maybe TaggableResourceType -> Int -> DeleteTagsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe TaggableResourceType -> Int -> DeleteTagsResponse)
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
"ResourceId")
            Either
  String (Maybe TaggableResourceType -> Int -> DeleteTagsResponse)
-> Either String (Maybe TaggableResourceType)
-> Either String (Int -> DeleteTagsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe TaggableResourceType)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ResourceType")
            Either String (Int -> DeleteTagsResponse)
-> Either String Int -> Either String DeleteTagsResponse
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 DeleteTags

instance Prelude.NFData DeleteTags

instance Core.ToHeaders DeleteTags where
  toHeaders :: DeleteTags -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteTags -> 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
"AmazonML_20141212.DeleteTags" ::
                          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 DeleteTags where
  toJSON :: DeleteTags -> Value
toJSON DeleteTags' {[Text]
Text
TaggableResourceType
resourceType :: TaggableResourceType
resourceId :: Text
tagKeys :: [Text]
$sel:resourceType:DeleteTags' :: DeleteTags -> TaggableResourceType
$sel:resourceId:DeleteTags' :: DeleteTags -> Text
$sel:tagKeys:DeleteTags' :: DeleteTags -> [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
"TagKeys" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
tagKeys),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ResourceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ResourceType" Text -> TaggableResourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TaggableResourceType
resourceType)
          ]
      )

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

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

-- | Amazon ML returns the following elements.
--
-- /See:/ 'newDeleteTagsResponse' smart constructor.
data DeleteTagsResponse = DeleteTagsResponse'
  { -- | The ID of the ML object from which tags were deleted.
    DeleteTagsResponse -> Maybe Text
resourceId :: Prelude.Maybe Prelude.Text,
    -- | The type of the ML object from which tags were deleted.
    DeleteTagsResponse -> Maybe TaggableResourceType
resourceType :: Prelude.Maybe TaggableResourceType,
    -- | The response's http status code.
    DeleteTagsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteTagsResponse -> DeleteTagsResponse -> Bool
(DeleteTagsResponse -> DeleteTagsResponse -> Bool)
-> (DeleteTagsResponse -> DeleteTagsResponse -> Bool)
-> Eq DeleteTagsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteTagsResponse -> DeleteTagsResponse -> Bool
$c/= :: DeleteTagsResponse -> DeleteTagsResponse -> Bool
== :: DeleteTagsResponse -> DeleteTagsResponse -> Bool
$c== :: DeleteTagsResponse -> DeleteTagsResponse -> Bool
Prelude.Eq, ReadPrec [DeleteTagsResponse]
ReadPrec DeleteTagsResponse
Int -> ReadS DeleteTagsResponse
ReadS [DeleteTagsResponse]
(Int -> ReadS DeleteTagsResponse)
-> ReadS [DeleteTagsResponse]
-> ReadPrec DeleteTagsResponse
-> ReadPrec [DeleteTagsResponse]
-> Read DeleteTagsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteTagsResponse]
$creadListPrec :: ReadPrec [DeleteTagsResponse]
readPrec :: ReadPrec DeleteTagsResponse
$creadPrec :: ReadPrec DeleteTagsResponse
readList :: ReadS [DeleteTagsResponse]
$creadList :: ReadS [DeleteTagsResponse]
readsPrec :: Int -> ReadS DeleteTagsResponse
$creadsPrec :: Int -> ReadS DeleteTagsResponse
Prelude.Read, Int -> DeleteTagsResponse -> ShowS
[DeleteTagsResponse] -> ShowS
DeleteTagsResponse -> String
(Int -> DeleteTagsResponse -> ShowS)
-> (DeleteTagsResponse -> String)
-> ([DeleteTagsResponse] -> ShowS)
-> Show DeleteTagsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteTagsResponse] -> ShowS
$cshowList :: [DeleteTagsResponse] -> ShowS
show :: DeleteTagsResponse -> String
$cshow :: DeleteTagsResponse -> String
showsPrec :: Int -> DeleteTagsResponse -> ShowS
$cshowsPrec :: Int -> DeleteTagsResponse -> ShowS
Prelude.Show, (forall x. DeleteTagsResponse -> Rep DeleteTagsResponse x)
-> (forall x. Rep DeleteTagsResponse x -> DeleteTagsResponse)
-> Generic DeleteTagsResponse
forall x. Rep DeleteTagsResponse x -> DeleteTagsResponse
forall x. DeleteTagsResponse -> Rep DeleteTagsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteTagsResponse x -> DeleteTagsResponse
$cfrom :: forall x. DeleteTagsResponse -> Rep DeleteTagsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteTagsResponse' 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:
--
-- 'resourceId', 'deleteTagsResponse_resourceId' - The ID of the ML object from which tags were deleted.
--
-- 'resourceType', 'deleteTagsResponse_resourceType' - The type of the ML object from which tags were deleted.
--
-- 'httpStatus', 'deleteTagsResponse_httpStatus' - The response's http status code.
newDeleteTagsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteTagsResponse
newDeleteTagsResponse :: Int -> DeleteTagsResponse
newDeleteTagsResponse Int
pHttpStatus_ =
  DeleteTagsResponse' :: Maybe Text
-> Maybe TaggableResourceType -> Int -> DeleteTagsResponse
DeleteTagsResponse'
    { $sel:resourceId:DeleteTagsResponse' :: Maybe Text
resourceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:DeleteTagsResponse' :: Maybe TaggableResourceType
resourceType = Maybe TaggableResourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteTagsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ID of the ML object from which tags were deleted.
deleteTagsResponse_resourceId :: Lens.Lens' DeleteTagsResponse (Prelude.Maybe Prelude.Text)
deleteTagsResponse_resourceId :: (Maybe Text -> f (Maybe Text))
-> DeleteTagsResponse -> f DeleteTagsResponse
deleteTagsResponse_resourceId = (DeleteTagsResponse -> Maybe Text)
-> (DeleteTagsResponse -> Maybe Text -> DeleteTagsResponse)
-> Lens
     DeleteTagsResponse DeleteTagsResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTagsResponse' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:DeleteTagsResponse' :: DeleteTagsResponse -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: DeleteTagsResponse
s@DeleteTagsResponse' {} Maybe Text
a -> DeleteTagsResponse
s {$sel:resourceId:DeleteTagsResponse' :: Maybe Text
resourceId = Maybe Text
a} :: DeleteTagsResponse)

-- | The type of the ML object from which tags were deleted.
deleteTagsResponse_resourceType :: Lens.Lens' DeleteTagsResponse (Prelude.Maybe TaggableResourceType)
deleteTagsResponse_resourceType :: (Maybe TaggableResourceType -> f (Maybe TaggableResourceType))
-> DeleteTagsResponse -> f DeleteTagsResponse
deleteTagsResponse_resourceType = (DeleteTagsResponse -> Maybe TaggableResourceType)
-> (DeleteTagsResponse
    -> Maybe TaggableResourceType -> DeleteTagsResponse)
-> Lens
     DeleteTagsResponse
     DeleteTagsResponse
     (Maybe TaggableResourceType)
     (Maybe TaggableResourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTagsResponse' {Maybe TaggableResourceType
resourceType :: Maybe TaggableResourceType
$sel:resourceType:DeleteTagsResponse' :: DeleteTagsResponse -> Maybe TaggableResourceType
resourceType} -> Maybe TaggableResourceType
resourceType) (\s :: DeleteTagsResponse
s@DeleteTagsResponse' {} Maybe TaggableResourceType
a -> DeleteTagsResponse
s {$sel:resourceType:DeleteTagsResponse' :: Maybe TaggableResourceType
resourceType = Maybe TaggableResourceType
a} :: DeleteTagsResponse)

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

instance Prelude.NFData DeleteTagsResponse