{-# 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 #-}
module Amazonka.ResourceGroupsTagging.TagResources
(
TagResources (..),
newTagResources,
tagResources_resourceARNList,
tagResources_tags,
TagResourcesResponse (..),
newTagResourcesResponse,
tagResourcesResponse_failedResourcesMap,
tagResourcesResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import Amazonka.ResourceGroupsTagging.Types
import qualified Amazonka.Response as Response
data TagResources = TagResources'
{
TagResources -> NonEmpty Text
resourceARNList :: Prelude.NonEmpty Prelude.Text,
TagResources -> HashMap Text Text
tags :: Prelude.HashMap Prelude.Text Prelude.Text
}
deriving (TagResources -> TagResources -> Bool
(TagResources -> TagResources -> Bool)
-> (TagResources -> TagResources -> Bool) -> Eq TagResources
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagResources -> TagResources -> Bool
$c/= :: TagResources -> TagResources -> Bool
== :: TagResources -> TagResources -> Bool
$c== :: TagResources -> TagResources -> Bool
Prelude.Eq, ReadPrec [TagResources]
ReadPrec TagResources
Int -> ReadS TagResources
ReadS [TagResources]
(Int -> ReadS TagResources)
-> ReadS [TagResources]
-> ReadPrec TagResources
-> ReadPrec [TagResources]
-> Read TagResources
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagResources]
$creadListPrec :: ReadPrec [TagResources]
readPrec :: ReadPrec TagResources
$creadPrec :: ReadPrec TagResources
readList :: ReadS [TagResources]
$creadList :: ReadS [TagResources]
readsPrec :: Int -> ReadS TagResources
$creadsPrec :: Int -> ReadS TagResources
Prelude.Read, Int -> TagResources -> ShowS
[TagResources] -> ShowS
TagResources -> String
(Int -> TagResources -> ShowS)
-> (TagResources -> String)
-> ([TagResources] -> ShowS)
-> Show TagResources
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagResources] -> ShowS
$cshowList :: [TagResources] -> ShowS
show :: TagResources -> String
$cshow :: TagResources -> String
showsPrec :: Int -> TagResources -> ShowS
$cshowsPrec :: Int -> TagResources -> ShowS
Prelude.Show, (forall x. TagResources -> Rep TagResources x)
-> (forall x. Rep TagResources x -> TagResources)
-> Generic TagResources
forall x. Rep TagResources x -> TagResources
forall x. TagResources -> Rep TagResources x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagResources x -> TagResources
$cfrom :: forall x. TagResources -> Rep TagResources x
Prelude.Generic)
newTagResources ::
Prelude.NonEmpty Prelude.Text ->
TagResources
newTagResources :: NonEmpty Text -> TagResources
newTagResources NonEmpty Text
pResourceARNList_ =
TagResources' :: NonEmpty Text -> HashMap Text Text -> TagResources
TagResources'
{ $sel:resourceARNList:TagResources' :: NonEmpty Text
resourceARNList =
Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pResourceARNList_,
$sel:tags:TagResources' :: HashMap Text Text
tags = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
}
tagResources_resourceARNList :: Lens.Lens' TagResources (Prelude.NonEmpty Prelude.Text)
tagResources_resourceARNList :: (NonEmpty Text -> f (NonEmpty Text))
-> TagResources -> f TagResources
tagResources_resourceARNList = (TagResources -> NonEmpty Text)
-> (TagResources -> NonEmpty Text -> TagResources)
-> Lens TagResources TagResources (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagResources' {NonEmpty Text
resourceARNList :: NonEmpty Text
$sel:resourceARNList:TagResources' :: TagResources -> NonEmpty Text
resourceARNList} -> NonEmpty Text
resourceARNList) (\s :: TagResources
s@TagResources' {} NonEmpty Text
a -> TagResources
s {$sel:resourceARNList:TagResources' :: NonEmpty Text
resourceARNList = NonEmpty Text
a} :: TagResources) ((NonEmpty Text -> f (NonEmpty Text))
-> TagResources -> f TagResources)
-> ((NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> TagResources
-> f TagResources
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
tagResources_tags :: Lens.Lens' TagResources (Prelude.HashMap Prelude.Text Prelude.Text)
tagResources_tags :: (HashMap Text Text -> f (HashMap Text Text))
-> TagResources -> f TagResources
tagResources_tags = (TagResources -> HashMap Text Text)
-> (TagResources -> HashMap Text Text -> TagResources)
-> Lens
TagResources TagResources (HashMap Text Text) (HashMap Text Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagResources' {HashMap Text Text
tags :: HashMap Text Text
$sel:tags:TagResources' :: TagResources -> HashMap Text Text
tags} -> HashMap Text Text
tags) (\s :: TagResources
s@TagResources' {} HashMap Text Text
a -> TagResources
s {$sel:tags:TagResources' :: HashMap Text Text
tags = HashMap Text Text
a} :: TagResources) ((HashMap Text Text -> f (HashMap Text Text))
-> TagResources -> f TagResources)
-> ((HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> TagResources
-> f TagResources
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest TagResources where
type AWSResponse TagResources = TagResourcesResponse
request :: TagResources -> Request TagResources
request = Service -> TagResources -> Request TagResources
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy TagResources
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TagResources)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse TagResources))
-> Logger
-> Service
-> Proxy TagResources
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TagResources)))
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 (HashMap Text FailureInfo) -> Int -> TagResourcesResponse
TagResourcesResponse'
(Maybe (HashMap Text FailureInfo) -> Int -> TagResourcesResponse)
-> Either String (Maybe (HashMap Text FailureInfo))
-> Either String (Int -> TagResourcesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Either String (Maybe (Maybe (HashMap Text FailureInfo)))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FailedResourcesMap"
Either String (Maybe (Maybe (HashMap Text FailureInfo)))
-> Maybe (HashMap Text FailureInfo)
-> Either String (Maybe (HashMap Text FailureInfo))
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe (HashMap Text FailureInfo)
forall a. Monoid a => a
Prelude.mempty
)
Either String (Int -> TagResourcesResponse)
-> Either String Int -> Either String TagResourcesResponse
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 TagResources
instance Prelude.NFData TagResources
instance Core.ToHeaders TagResources where
toHeaders :: TagResources -> ResponseHeaders
toHeaders =
ResponseHeaders -> TagResources -> 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
"ResourceGroupsTaggingAPI_20170126.TagResources" ::
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 TagResources where
toJSON :: TagResources -> Value
toJSON TagResources' {NonEmpty Text
HashMap Text Text
tags :: HashMap Text Text
resourceARNList :: NonEmpty Text
$sel:tags:TagResources' :: TagResources -> HashMap Text Text
$sel:resourceARNList:TagResources' :: TagResources -> NonEmpty 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
"ResourceARNList" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
resourceARNList),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text Text
tags)
]
)
instance Core.ToPath TagResources where
toPath :: TagResources -> ByteString
toPath = ByteString -> TagResources -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery TagResources where
toQuery :: TagResources -> QueryString
toQuery = QueryString -> TagResources -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data TagResourcesResponse = TagResourcesResponse'
{
TagResourcesResponse -> Maybe (HashMap Text FailureInfo)
failedResourcesMap :: Prelude.Maybe (Prelude.HashMap Prelude.Text FailureInfo),
TagResourcesResponse -> Int
httpStatus :: Prelude.Int
}
deriving (TagResourcesResponse -> TagResourcesResponse -> Bool
(TagResourcesResponse -> TagResourcesResponse -> Bool)
-> (TagResourcesResponse -> TagResourcesResponse -> Bool)
-> Eq TagResourcesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagResourcesResponse -> TagResourcesResponse -> Bool
$c/= :: TagResourcesResponse -> TagResourcesResponse -> Bool
== :: TagResourcesResponse -> TagResourcesResponse -> Bool
$c== :: TagResourcesResponse -> TagResourcesResponse -> Bool
Prelude.Eq, ReadPrec [TagResourcesResponse]
ReadPrec TagResourcesResponse
Int -> ReadS TagResourcesResponse
ReadS [TagResourcesResponse]
(Int -> ReadS TagResourcesResponse)
-> ReadS [TagResourcesResponse]
-> ReadPrec TagResourcesResponse
-> ReadPrec [TagResourcesResponse]
-> Read TagResourcesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagResourcesResponse]
$creadListPrec :: ReadPrec [TagResourcesResponse]
readPrec :: ReadPrec TagResourcesResponse
$creadPrec :: ReadPrec TagResourcesResponse
readList :: ReadS [TagResourcesResponse]
$creadList :: ReadS [TagResourcesResponse]
readsPrec :: Int -> ReadS TagResourcesResponse
$creadsPrec :: Int -> ReadS TagResourcesResponse
Prelude.Read, Int -> TagResourcesResponse -> ShowS
[TagResourcesResponse] -> ShowS
TagResourcesResponse -> String
(Int -> TagResourcesResponse -> ShowS)
-> (TagResourcesResponse -> String)
-> ([TagResourcesResponse] -> ShowS)
-> Show TagResourcesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagResourcesResponse] -> ShowS
$cshowList :: [TagResourcesResponse] -> ShowS
show :: TagResourcesResponse -> String
$cshow :: TagResourcesResponse -> String
showsPrec :: Int -> TagResourcesResponse -> ShowS
$cshowsPrec :: Int -> TagResourcesResponse -> ShowS
Prelude.Show, (forall x. TagResourcesResponse -> Rep TagResourcesResponse x)
-> (forall x. Rep TagResourcesResponse x -> TagResourcesResponse)
-> Generic TagResourcesResponse
forall x. Rep TagResourcesResponse x -> TagResourcesResponse
forall x. TagResourcesResponse -> Rep TagResourcesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagResourcesResponse x -> TagResourcesResponse
$cfrom :: forall x. TagResourcesResponse -> Rep TagResourcesResponse x
Prelude.Generic)
newTagResourcesResponse ::
Prelude.Int ->
TagResourcesResponse
newTagResourcesResponse :: Int -> TagResourcesResponse
newTagResourcesResponse Int
pHttpStatus_ =
TagResourcesResponse' :: Maybe (HashMap Text FailureInfo) -> Int -> TagResourcesResponse
TagResourcesResponse'
{ $sel:failedResourcesMap:TagResourcesResponse' :: Maybe (HashMap Text FailureInfo)
failedResourcesMap =
Maybe (HashMap Text FailureInfo)
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:TagResourcesResponse' :: Int
httpStatus = Int
pHttpStatus_
}
tagResourcesResponse_failedResourcesMap :: Lens.Lens' TagResourcesResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text FailureInfo))
tagResourcesResponse_failedResourcesMap :: (Maybe (HashMap Text FailureInfo)
-> f (Maybe (HashMap Text FailureInfo)))
-> TagResourcesResponse -> f TagResourcesResponse
tagResourcesResponse_failedResourcesMap = (TagResourcesResponse -> Maybe (HashMap Text FailureInfo))
-> (TagResourcesResponse
-> Maybe (HashMap Text FailureInfo) -> TagResourcesResponse)
-> Lens
TagResourcesResponse
TagResourcesResponse
(Maybe (HashMap Text FailureInfo))
(Maybe (HashMap Text FailureInfo))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagResourcesResponse' {Maybe (HashMap Text FailureInfo)
failedResourcesMap :: Maybe (HashMap Text FailureInfo)
$sel:failedResourcesMap:TagResourcesResponse' :: TagResourcesResponse -> Maybe (HashMap Text FailureInfo)
failedResourcesMap} -> Maybe (HashMap Text FailureInfo)
failedResourcesMap) (\s :: TagResourcesResponse
s@TagResourcesResponse' {} Maybe (HashMap Text FailureInfo)
a -> TagResourcesResponse
s {$sel:failedResourcesMap:TagResourcesResponse' :: Maybe (HashMap Text FailureInfo)
failedResourcesMap = Maybe (HashMap Text FailureInfo)
a} :: TagResourcesResponse) ((Maybe (HashMap Text FailureInfo)
-> f (Maybe (HashMap Text FailureInfo)))
-> TagResourcesResponse -> f TagResourcesResponse)
-> ((Maybe (HashMap Text FailureInfo)
-> f (Maybe (HashMap Text FailureInfo)))
-> Maybe (HashMap Text FailureInfo)
-> f (Maybe (HashMap Text FailureInfo)))
-> (Maybe (HashMap Text FailureInfo)
-> f (Maybe (HashMap Text FailureInfo)))
-> TagResourcesResponse
-> f TagResourcesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text FailureInfo)
(HashMap Text FailureInfo)
(HashMap Text FailureInfo)
(HashMap Text FailureInfo)
-> Iso
(Maybe (HashMap Text FailureInfo))
(Maybe (HashMap Text FailureInfo))
(Maybe (HashMap Text FailureInfo))
(Maybe (HashMap Text FailureInfo))
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
(HashMap Text FailureInfo)
(HashMap Text FailureInfo)
(HashMap Text FailureInfo)
(HashMap Text FailureInfo)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
tagResourcesResponse_httpStatus :: Lens.Lens' TagResourcesResponse Prelude.Int
tagResourcesResponse_httpStatus :: (Int -> f Int) -> TagResourcesResponse -> f TagResourcesResponse
tagResourcesResponse_httpStatus = (TagResourcesResponse -> Int)
-> (TagResourcesResponse -> Int -> TagResourcesResponse)
-> Lens TagResourcesResponse TagResourcesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagResourcesResponse' {Int
httpStatus :: Int
$sel:httpStatus:TagResourcesResponse' :: TagResourcesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: TagResourcesResponse
s@TagResourcesResponse' {} Int
a -> TagResourcesResponse
s {$sel:httpStatus:TagResourcesResponse' :: Int
httpStatus = Int
a} :: TagResourcesResponse)
instance Prelude.NFData TagResourcesResponse