{-# 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.Discovery.CreateTags
-- 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)
--
-- Creates one or more tags for configuration items. Tags are metadata that
-- help you categorize IT assets. This API accepts a list of multiple
-- configuration items.
module Amazonka.Discovery.CreateTags
  ( -- * Creating a Request
    CreateTags (..),
    newCreateTags,

    -- * Request Lenses
    createTags_configurationIds,
    createTags_tags,

    -- * Destructuring the Response
    CreateTagsResponse (..),
    newCreateTagsResponse,

    -- * Response Lenses
    createTagsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Discovery.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:/ 'newCreateTags' smart constructor.
data CreateTags = CreateTags'
  { -- | A list of configuration items that you want to tag.
    CreateTags -> [Text]
configurationIds :: [Prelude.Text],
    -- | Tags that you want to associate with one or more configuration items.
    -- Specify the tags that you want to create in a /key/-/value/ format. For
    -- example:
    --
    -- @{\"key\": \"serverType\", \"value\": \"webServer\"}@
    CreateTags -> [Tag]
tags :: [Tag]
  }
  deriving (CreateTags -> CreateTags -> Bool
(CreateTags -> CreateTags -> Bool)
-> (CreateTags -> CreateTags -> Bool) -> Eq CreateTags
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTags -> CreateTags -> Bool
$c/= :: CreateTags -> CreateTags -> Bool
== :: CreateTags -> CreateTags -> Bool
$c== :: CreateTags -> CreateTags -> Bool
Prelude.Eq, ReadPrec [CreateTags]
ReadPrec CreateTags
Int -> ReadS CreateTags
ReadS [CreateTags]
(Int -> ReadS CreateTags)
-> ReadS [CreateTags]
-> ReadPrec CreateTags
-> ReadPrec [CreateTags]
-> Read CreateTags
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTags]
$creadListPrec :: ReadPrec [CreateTags]
readPrec :: ReadPrec CreateTags
$creadPrec :: ReadPrec CreateTags
readList :: ReadS [CreateTags]
$creadList :: ReadS [CreateTags]
readsPrec :: Int -> ReadS CreateTags
$creadsPrec :: Int -> ReadS CreateTags
Prelude.Read, Int -> CreateTags -> ShowS
[CreateTags] -> ShowS
CreateTags -> String
(Int -> CreateTags -> ShowS)
-> (CreateTags -> String)
-> ([CreateTags] -> ShowS)
-> Show CreateTags
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTags] -> ShowS
$cshowList :: [CreateTags] -> ShowS
show :: CreateTags -> String
$cshow :: CreateTags -> String
showsPrec :: Int -> CreateTags -> ShowS
$cshowsPrec :: Int -> CreateTags -> ShowS
Prelude.Show, (forall x. CreateTags -> Rep CreateTags x)
-> (forall x. Rep CreateTags x -> CreateTags) -> Generic CreateTags
forall x. Rep CreateTags x -> CreateTags
forall x. CreateTags -> Rep CreateTags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTags x -> CreateTags
$cfrom :: forall x. CreateTags -> Rep CreateTags x
Prelude.Generic)

-- |
-- Create a value of 'CreateTags' 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:
--
-- 'configurationIds', 'createTags_configurationIds' - A list of configuration items that you want to tag.
--
-- 'tags', 'createTags_tags' - Tags that you want to associate with one or more configuration items.
-- Specify the tags that you want to create in a /key/-/value/ format. For
-- example:
--
-- @{\"key\": \"serverType\", \"value\": \"webServer\"}@
newCreateTags ::
  CreateTags
newCreateTags :: CreateTags
newCreateTags =
  CreateTags' :: [Text] -> [Tag] -> CreateTags
CreateTags'
    { $sel:configurationIds:CreateTags' :: [Text]
configurationIds = [Text]
forall a. Monoid a => a
Prelude.mempty,
      $sel:tags:CreateTags' :: [Tag]
tags = [Tag]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A list of configuration items that you want to tag.
createTags_configurationIds :: Lens.Lens' CreateTags [Prelude.Text]
createTags_configurationIds :: ([Text] -> f [Text]) -> CreateTags -> f CreateTags
createTags_configurationIds = (CreateTags -> [Text])
-> (CreateTags -> [Text] -> CreateTags)
-> Lens CreateTags CreateTags [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTags' {[Text]
configurationIds :: [Text]
$sel:configurationIds:CreateTags' :: CreateTags -> [Text]
configurationIds} -> [Text]
configurationIds) (\s :: CreateTags
s@CreateTags' {} [Text]
a -> CreateTags
s {$sel:configurationIds:CreateTags' :: [Text]
configurationIds = [Text]
a} :: CreateTags) (([Text] -> f [Text]) -> CreateTags -> f CreateTags)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> CreateTags
-> f CreateTags
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

-- | Tags that you want to associate with one or more configuration items.
-- Specify the tags that you want to create in a /key/-/value/ format. For
-- example:
--
-- @{\"key\": \"serverType\", \"value\": \"webServer\"}@
createTags_tags :: Lens.Lens' CreateTags [Tag]
createTags_tags :: ([Tag] -> f [Tag]) -> CreateTags -> f CreateTags
createTags_tags = (CreateTags -> [Tag])
-> (CreateTags -> [Tag] -> CreateTags)
-> Lens CreateTags CreateTags [Tag] [Tag]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTags' {[Tag]
tags :: [Tag]
$sel:tags:CreateTags' :: CreateTags -> [Tag]
tags} -> [Tag]
tags) (\s :: CreateTags
s@CreateTags' {} [Tag]
a -> CreateTags
s {$sel:tags:CreateTags' :: [Tag]
tags = [Tag]
a} :: CreateTags) (([Tag] -> f [Tag]) -> CreateTags -> f CreateTags)
-> (([Tag] -> f [Tag]) -> [Tag] -> f [Tag])
-> ([Tag] -> f [Tag])
-> CreateTags
-> f CreateTags
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Tag] -> f [Tag]) -> [Tag] -> f [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateTags where
  type AWSResponse CreateTags = CreateTagsResponse
  request :: CreateTags -> Request CreateTags
request = Service -> CreateTags -> Request CreateTags
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTags)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse CreateTags))
-> Logger
-> Service
-> Proxy CreateTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTags)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CreateTagsResponse
CreateTagsResponse'
            (Int -> CreateTagsResponse)
-> Either String Int -> Either String CreateTagsResponse
forall (f :: * -> *) a b. Functor 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 CreateTags

instance Prelude.NFData CreateTags

instance Core.ToHeaders CreateTags where
  toHeaders :: CreateTags -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateTags -> 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
"AWSPoseidonService_V2015_11_01.CreateTags" ::
                          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 CreateTags where
  toJSON :: CreateTags -> Value
toJSON CreateTags' {[Text]
[Tag]
tags :: [Tag]
configurationIds :: [Text]
$sel:tags:CreateTags' :: CreateTags -> [Tag]
$sel:configurationIds:CreateTags' :: CreateTags -> [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
"configurationIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
configurationIds),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Tag]
tags)
          ]
      )

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

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

-- | /See:/ 'newCreateTagsResponse' smart constructor.
data CreateTagsResponse = CreateTagsResponse'
  { -- | The response's http status code.
    CreateTagsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateTagsResponse -> CreateTagsResponse -> Bool
(CreateTagsResponse -> CreateTagsResponse -> Bool)
-> (CreateTagsResponse -> CreateTagsResponse -> Bool)
-> Eq CreateTagsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTagsResponse -> CreateTagsResponse -> Bool
$c/= :: CreateTagsResponse -> CreateTagsResponse -> Bool
== :: CreateTagsResponse -> CreateTagsResponse -> Bool
$c== :: CreateTagsResponse -> CreateTagsResponse -> Bool
Prelude.Eq, ReadPrec [CreateTagsResponse]
ReadPrec CreateTagsResponse
Int -> ReadS CreateTagsResponse
ReadS [CreateTagsResponse]
(Int -> ReadS CreateTagsResponse)
-> ReadS [CreateTagsResponse]
-> ReadPrec CreateTagsResponse
-> ReadPrec [CreateTagsResponse]
-> Read CreateTagsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTagsResponse]
$creadListPrec :: ReadPrec [CreateTagsResponse]
readPrec :: ReadPrec CreateTagsResponse
$creadPrec :: ReadPrec CreateTagsResponse
readList :: ReadS [CreateTagsResponse]
$creadList :: ReadS [CreateTagsResponse]
readsPrec :: Int -> ReadS CreateTagsResponse
$creadsPrec :: Int -> ReadS CreateTagsResponse
Prelude.Read, Int -> CreateTagsResponse -> ShowS
[CreateTagsResponse] -> ShowS
CreateTagsResponse -> String
(Int -> CreateTagsResponse -> ShowS)
-> (CreateTagsResponse -> String)
-> ([CreateTagsResponse] -> ShowS)
-> Show CreateTagsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTagsResponse] -> ShowS
$cshowList :: [CreateTagsResponse] -> ShowS
show :: CreateTagsResponse -> String
$cshow :: CreateTagsResponse -> String
showsPrec :: Int -> CreateTagsResponse -> ShowS
$cshowsPrec :: Int -> CreateTagsResponse -> ShowS
Prelude.Show, (forall x. CreateTagsResponse -> Rep CreateTagsResponse x)
-> (forall x. Rep CreateTagsResponse x -> CreateTagsResponse)
-> Generic CreateTagsResponse
forall x. Rep CreateTagsResponse x -> CreateTagsResponse
forall x. CreateTagsResponse -> Rep CreateTagsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTagsResponse x -> CreateTagsResponse
$cfrom :: forall x. CreateTagsResponse -> Rep CreateTagsResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateTagsResponse' 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:
--
-- 'httpStatus', 'createTagsResponse_httpStatus' - The response's http status code.
newCreateTagsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateTagsResponse
newCreateTagsResponse :: Int -> CreateTagsResponse
newCreateTagsResponse Int
pHttpStatus_ =
  CreateTagsResponse' :: Int -> CreateTagsResponse
CreateTagsResponse' {$sel:httpStatus:CreateTagsResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData CreateTagsResponse