{-# 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.DescribeTags
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describes one or more of the tags for your Amazon ML object.
module Amazonka.MachineLearning.DescribeTags
  ( -- * Creating a Request
    DescribeTags (..),
    newDescribeTags,

    -- * Request Lenses
    describeTags_resourceId,
    describeTags_resourceType,

    -- * Destructuring the Response
    DescribeTagsResponse (..),
    newDescribeTagsResponse,

    -- * Response Lenses
    describeTagsResponse_resourceId,
    describeTagsResponse_resourceType,
    describeTagsResponse_tags,
    describeTagsResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'DescribeTags' 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', 'describeTags_resourceId' - The ID of the ML object. For example, @exampleModelId@.
--
-- 'resourceType', 'describeTags_resourceType' - The type of the ML object.
newDescribeTags ::
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'resourceType'
  TaggableResourceType ->
  DescribeTags
newDescribeTags :: Text -> TaggableResourceType -> DescribeTags
newDescribeTags Text
pResourceId_ TaggableResourceType
pResourceType_ =
  DescribeTags'
    { $sel:resourceId:DescribeTags' :: Text
resourceId = Text
pResourceId_,
      $sel:resourceType:DescribeTags' :: TaggableResourceType
resourceType = TaggableResourceType
pResourceType_
    }

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

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

instance Core.AWSRequest DescribeTags where
  type AWSResponse DescribeTags = DescribeTagsResponse
  request :: (Service -> Service) -> DescribeTags -> Request DescribeTags
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 DescribeTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeTags)))
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 Text
-> Maybe TaggableResourceType
-> Maybe [Tag]
-> Int
-> DescribeTagsResponse
DescribeTagsResponse'
            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
"ResourceId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ResourceType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Tags" 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 DescribeTags where
  hashWithSalt :: Int -> DescribeTags -> Int
hashWithSalt Int
_salt DescribeTags' {Text
TaggableResourceType
resourceType :: TaggableResourceType
resourceId :: Text
$sel:resourceType:DescribeTags' :: DescribeTags -> TaggableResourceType
$sel:resourceId:DescribeTags' :: DescribeTags -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TaggableResourceType
resourceType

instance Prelude.NFData DescribeTags where
  rnf :: DescribeTags -> ()
rnf DescribeTags' {Text
TaggableResourceType
resourceType :: TaggableResourceType
resourceId :: Text
$sel:resourceType:DescribeTags' :: DescribeTags -> TaggableResourceType
$sel:resourceId:DescribeTags' :: DescribeTags -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf TaggableResourceType
resourceType

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

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

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

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

-- |
-- Create a value of 'DescribeTagsResponse' 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', 'describeTagsResponse_resourceId' - The ID of the tagged ML object.
--
-- 'resourceType', 'describeTagsResponse_resourceType' - The type of the tagged ML object.
--
-- 'tags', 'describeTagsResponse_tags' - A list of tags associated with the ML object.
--
-- 'httpStatus', 'describeTagsResponse_httpStatus' - The response's http status code.
newDescribeTagsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeTagsResponse
newDescribeTagsResponse :: Int -> DescribeTagsResponse
newDescribeTagsResponse Int
pHttpStatus_ =
  DescribeTagsResponse'
    { $sel:resourceId:DescribeTagsResponse' :: Maybe Text
resourceId = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:DescribeTagsResponse' :: Maybe TaggableResourceType
resourceType = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:DescribeTagsResponse' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeTagsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ID of the tagged ML object.
describeTagsResponse_resourceId :: Lens.Lens' DescribeTagsResponse (Prelude.Maybe Prelude.Text)
describeTagsResponse_resourceId :: Lens' DescribeTagsResponse (Maybe Text)
describeTagsResponse_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTagsResponse' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:DescribeTagsResponse' :: DescribeTagsResponse -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: DescribeTagsResponse
s@DescribeTagsResponse' {} Maybe Text
a -> DescribeTagsResponse
s {$sel:resourceId:DescribeTagsResponse' :: Maybe Text
resourceId = Maybe Text
a} :: DescribeTagsResponse)

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

-- | A list of tags associated with the ML object.
describeTagsResponse_tags :: Lens.Lens' DescribeTagsResponse (Prelude.Maybe [Tag])
describeTagsResponse_tags :: Lens' DescribeTagsResponse (Maybe [Tag])
describeTagsResponse_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTagsResponse' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:DescribeTagsResponse' :: DescribeTagsResponse -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: DescribeTagsResponse
s@DescribeTagsResponse' {} Maybe [Tag]
a -> DescribeTagsResponse
s {$sel:tags:DescribeTagsResponse' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: DescribeTagsResponse) 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.
describeTagsResponse_httpStatus :: Lens.Lens' DescribeTagsResponse Prelude.Int
describeTagsResponse_httpStatus :: Lens' DescribeTagsResponse Int
describeTagsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTagsResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeTagsResponse' :: DescribeTagsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeTagsResponse
s@DescribeTagsResponse' {} Int
a -> DescribeTagsResponse
s {$sel:httpStatus:DescribeTagsResponse' :: Int
httpStatus = Int
a} :: DescribeTagsResponse)

instance Prelude.NFData DescribeTagsResponse where
  rnf :: DescribeTagsResponse -> ()
rnf DescribeTagsResponse' {Int
Maybe [Tag]
Maybe Text
Maybe TaggableResourceType
httpStatus :: Int
tags :: Maybe [Tag]
resourceType :: Maybe TaggableResourceType
resourceId :: Maybe Text
$sel:httpStatus:DescribeTagsResponse' :: DescribeTagsResponse -> Int
$sel:tags:DescribeTagsResponse' :: DescribeTagsResponse -> Maybe [Tag]
$sel:resourceType:DescribeTagsResponse' :: DescribeTagsResponse -> Maybe TaggableResourceType
$sel:resourceId:DescribeTagsResponse' :: DescribeTagsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TaggableResourceType
resourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus