{-# 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.DirectConnect.DescribeTags
-- 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)
--
-- Describes the tags associated with the specified Direct Connect
-- resources.
module Amazonka.DirectConnect.DescribeTags
  ( -- * Creating a Request
    DescribeTags (..),
    newDescribeTags,

    -- * Request Lenses
    describeTags_resourceArns,

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

    -- * Response Lenses
    describeTagsResponse_resourceTags,
    describeTagsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DirectConnect.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:/ 'newDescribeTags' smart constructor.
data DescribeTags = DescribeTags'
  { -- | The Amazon Resource Names (ARNs) of the resources.
    DescribeTags -> [Text]
resourceArns :: [Prelude.Text]
  }
  deriving (DescribeTags -> DescribeTags -> Bool
(DescribeTags -> DescribeTags -> Bool)
-> (DescribeTags -> DescribeTags -> Bool) -> Eq DescribeTags
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]
(Int -> ReadS DescribeTags)
-> ReadS [DescribeTags]
-> ReadPrec DescribeTags
-> ReadPrec [DescribeTags]
-> Read 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
(Int -> DescribeTags -> ShowS)
-> (DescribeTags -> String)
-> ([DescribeTags] -> ShowS)
-> Show DescribeTags
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. DescribeTags -> Rep DescribeTags x)
-> (forall x. Rep DescribeTags x -> DescribeTags)
-> Generic DescribeTags
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:
--
-- 'resourceArns', 'describeTags_resourceArns' - The Amazon Resource Names (ARNs) of the resources.
newDescribeTags ::
  DescribeTags
newDescribeTags :: DescribeTags
newDescribeTags =
  DescribeTags' :: [Text] -> DescribeTags
DescribeTags' {$sel:resourceArns:DescribeTags' :: [Text]
resourceArns = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | The Amazon Resource Names (ARNs) of the resources.
describeTags_resourceArns :: Lens.Lens' DescribeTags [Prelude.Text]
describeTags_resourceArns :: ([Text] -> f [Text]) -> DescribeTags -> f DescribeTags
describeTags_resourceArns = (DescribeTags -> [Text])
-> (DescribeTags -> [Text] -> DescribeTags)
-> Lens DescribeTags DescribeTags [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTags' {[Text]
resourceArns :: [Text]
$sel:resourceArns:DescribeTags' :: DescribeTags -> [Text]
resourceArns} -> [Text]
resourceArns) (\s :: DescribeTags
s@DescribeTags' {} [Text]
a -> DescribeTags
s {$sel:resourceArns:DescribeTags' :: [Text]
resourceArns = [Text]
a} :: DescribeTags) (([Text] -> f [Text]) -> DescribeTags -> f DescribeTags)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DescribeTags
-> f DescribeTags
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 DescribeTags where
  type AWSResponse DescribeTags = DescribeTagsResponse
  request :: DescribeTags -> Request DescribeTags
request = Service -> DescribeTags -> Request DescribeTags
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeTags)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeTags))
-> Logger
-> Service
-> Proxy DescribeTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeTags)))
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 [ResourceTag] -> Int -> DescribeTagsResponse
DescribeTagsResponse'
            (Maybe [ResourceTag] -> Int -> DescribeTagsResponse)
-> Either String (Maybe [ResourceTag])
-> Either String (Int -> DescribeTagsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [ResourceTag]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"resourceTags" Either String (Maybe (Maybe [ResourceTag]))
-> Maybe [ResourceTag] -> Either String (Maybe [ResourceTag])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ResourceTag]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DescribeTagsResponse)
-> Either String Int -> Either String DescribeTagsResponse
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 DescribeTags

instance Prelude.NFData DescribeTags

instance Core.ToHeaders DescribeTags where
  toHeaders :: DescribeTags -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeTags -> 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
"OvertureService.DescribeTags" ::
                          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 DescribeTags where
  toJSON :: DescribeTags -> Value
toJSON DescribeTags' {[Text]
resourceArns :: [Text]
$sel:resourceArns:DescribeTags' :: DescribeTags -> [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
"resourceArns" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
resourceArns)]
      )

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

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

-- | /See:/ 'newDescribeTagsResponse' smart constructor.
data DescribeTagsResponse = DescribeTagsResponse'
  { -- | Information about the tags.
    DescribeTagsResponse -> Maybe [ResourceTag]
resourceTags :: Prelude.Maybe [ResourceTag],
    -- | The response's http status code.
    DescribeTagsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeTagsResponse -> DescribeTagsResponse -> Bool
(DescribeTagsResponse -> DescribeTagsResponse -> Bool)
-> (DescribeTagsResponse -> DescribeTagsResponse -> Bool)
-> Eq DescribeTagsResponse
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]
(Int -> ReadS DescribeTagsResponse)
-> ReadS [DescribeTagsResponse]
-> ReadPrec DescribeTagsResponse
-> ReadPrec [DescribeTagsResponse]
-> Read 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
(Int -> DescribeTagsResponse -> ShowS)
-> (DescribeTagsResponse -> String)
-> ([DescribeTagsResponse] -> ShowS)
-> Show DescribeTagsResponse
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. DescribeTagsResponse -> Rep DescribeTagsResponse x)
-> (forall x. Rep DescribeTagsResponse x -> DescribeTagsResponse)
-> Generic DescribeTagsResponse
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:
--
-- 'resourceTags', 'describeTagsResponse_resourceTags' - Information about the tags.
--
-- 'httpStatus', 'describeTagsResponse_httpStatus' - The response's http status code.
newDescribeTagsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeTagsResponse
newDescribeTagsResponse :: Int -> DescribeTagsResponse
newDescribeTagsResponse Int
pHttpStatus_ =
  DescribeTagsResponse' :: Maybe [ResourceTag] -> Int -> DescribeTagsResponse
DescribeTagsResponse'
    { $sel:resourceTags:DescribeTagsResponse' :: Maybe [ResourceTag]
resourceTags =
        Maybe [ResourceTag]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeTagsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the tags.
describeTagsResponse_resourceTags :: Lens.Lens' DescribeTagsResponse (Prelude.Maybe [ResourceTag])
describeTagsResponse_resourceTags :: (Maybe [ResourceTag] -> f (Maybe [ResourceTag]))
-> DescribeTagsResponse -> f DescribeTagsResponse
describeTagsResponse_resourceTags = (DescribeTagsResponse -> Maybe [ResourceTag])
-> (DescribeTagsResponse
    -> Maybe [ResourceTag] -> DescribeTagsResponse)
-> Lens
     DescribeTagsResponse
     DescribeTagsResponse
     (Maybe [ResourceTag])
     (Maybe [ResourceTag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTagsResponse' {Maybe [ResourceTag]
resourceTags :: Maybe [ResourceTag]
$sel:resourceTags:DescribeTagsResponse' :: DescribeTagsResponse -> Maybe [ResourceTag]
resourceTags} -> Maybe [ResourceTag]
resourceTags) (\s :: DescribeTagsResponse
s@DescribeTagsResponse' {} Maybe [ResourceTag]
a -> DescribeTagsResponse
s {$sel:resourceTags:DescribeTagsResponse' :: Maybe [ResourceTag]
resourceTags = Maybe [ResourceTag]
a} :: DescribeTagsResponse) ((Maybe [ResourceTag] -> f (Maybe [ResourceTag]))
 -> DescribeTagsResponse -> f DescribeTagsResponse)
-> ((Maybe [ResourceTag] -> f (Maybe [ResourceTag]))
    -> Maybe [ResourceTag] -> f (Maybe [ResourceTag]))
-> (Maybe [ResourceTag] -> f (Maybe [ResourceTag]))
-> DescribeTagsResponse
-> f DescribeTagsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ResourceTag] [ResourceTag] [ResourceTag] [ResourceTag]
-> Iso
     (Maybe [ResourceTag])
     (Maybe [ResourceTag])
     (Maybe [ResourceTag])
     (Maybe [ResourceTag])
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 [ResourceTag] [ResourceTag] [ResourceTag] [ResourceTag]
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 :: (Int -> f Int) -> DescribeTagsResponse -> f DescribeTagsResponse
describeTagsResponse_httpStatus = (DescribeTagsResponse -> Int)
-> (DescribeTagsResponse -> Int -> DescribeTagsResponse)
-> Lens DescribeTagsResponse DescribeTagsResponse Int Int
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