{-# 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.CodeDeploy.AddTagsToOnPremisesInstances
-- 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)
--
-- Adds tags to on-premises instances.
module Amazonka.CodeDeploy.AddTagsToOnPremisesInstances
  ( -- * Creating a Request
    AddTagsToOnPremisesInstances (..),
    newAddTagsToOnPremisesInstances,

    -- * Request Lenses
    addTagsToOnPremisesInstances_tags,
    addTagsToOnPremisesInstances_instanceNames,

    -- * Destructuring the Response
    AddTagsToOnPremisesInstancesResponse (..),
    newAddTagsToOnPremisesInstancesResponse,
  )
where

import Amazonka.CodeDeploy.Types
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 qualified Amazonka.Response as Response

-- | Represents the input of, and adds tags to, an on-premises instance
-- operation.
--
-- /See:/ 'newAddTagsToOnPremisesInstances' smart constructor.
data AddTagsToOnPremisesInstances = AddTagsToOnPremisesInstances'
  { -- | The tag key-value pairs to add to the on-premises instances.
    --
    -- Keys and values are both required. Keys cannot be null or empty strings.
    -- Value-only tags are not allowed.
    AddTagsToOnPremisesInstances -> [Tag]
tags :: [Tag],
    -- | The names of the on-premises instances to which to add tags.
    AddTagsToOnPremisesInstances -> [Text]
instanceNames :: [Prelude.Text]
  }
  deriving (AddTagsToOnPremisesInstances
-> AddTagsToOnPremisesInstances -> Bool
(AddTagsToOnPremisesInstances
 -> AddTagsToOnPremisesInstances -> Bool)
-> (AddTagsToOnPremisesInstances
    -> AddTagsToOnPremisesInstances -> Bool)
-> Eq AddTagsToOnPremisesInstances
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddTagsToOnPremisesInstances
-> AddTagsToOnPremisesInstances -> Bool
$c/= :: AddTagsToOnPremisesInstances
-> AddTagsToOnPremisesInstances -> Bool
== :: AddTagsToOnPremisesInstances
-> AddTagsToOnPremisesInstances -> Bool
$c== :: AddTagsToOnPremisesInstances
-> AddTagsToOnPremisesInstances -> Bool
Prelude.Eq, ReadPrec [AddTagsToOnPremisesInstances]
ReadPrec AddTagsToOnPremisesInstances
Int -> ReadS AddTagsToOnPremisesInstances
ReadS [AddTagsToOnPremisesInstances]
(Int -> ReadS AddTagsToOnPremisesInstances)
-> ReadS [AddTagsToOnPremisesInstances]
-> ReadPrec AddTagsToOnPremisesInstances
-> ReadPrec [AddTagsToOnPremisesInstances]
-> Read AddTagsToOnPremisesInstances
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddTagsToOnPremisesInstances]
$creadListPrec :: ReadPrec [AddTagsToOnPremisesInstances]
readPrec :: ReadPrec AddTagsToOnPremisesInstances
$creadPrec :: ReadPrec AddTagsToOnPremisesInstances
readList :: ReadS [AddTagsToOnPremisesInstances]
$creadList :: ReadS [AddTagsToOnPremisesInstances]
readsPrec :: Int -> ReadS AddTagsToOnPremisesInstances
$creadsPrec :: Int -> ReadS AddTagsToOnPremisesInstances
Prelude.Read, Int -> AddTagsToOnPremisesInstances -> ShowS
[AddTagsToOnPremisesInstances] -> ShowS
AddTagsToOnPremisesInstances -> String
(Int -> AddTagsToOnPremisesInstances -> ShowS)
-> (AddTagsToOnPremisesInstances -> String)
-> ([AddTagsToOnPremisesInstances] -> ShowS)
-> Show AddTagsToOnPremisesInstances
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddTagsToOnPremisesInstances] -> ShowS
$cshowList :: [AddTagsToOnPremisesInstances] -> ShowS
show :: AddTagsToOnPremisesInstances -> String
$cshow :: AddTagsToOnPremisesInstances -> String
showsPrec :: Int -> AddTagsToOnPremisesInstances -> ShowS
$cshowsPrec :: Int -> AddTagsToOnPremisesInstances -> ShowS
Prelude.Show, (forall x.
 AddTagsToOnPremisesInstances -> Rep AddTagsToOnPremisesInstances x)
-> (forall x.
    Rep AddTagsToOnPremisesInstances x -> AddTagsToOnPremisesInstances)
-> Generic AddTagsToOnPremisesInstances
forall x.
Rep AddTagsToOnPremisesInstances x -> AddTagsToOnPremisesInstances
forall x.
AddTagsToOnPremisesInstances -> Rep AddTagsToOnPremisesInstances x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AddTagsToOnPremisesInstances x -> AddTagsToOnPremisesInstances
$cfrom :: forall x.
AddTagsToOnPremisesInstances -> Rep AddTagsToOnPremisesInstances x
Prelude.Generic)

-- |
-- Create a value of 'AddTagsToOnPremisesInstances' 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:
--
-- 'tags', 'addTagsToOnPremisesInstances_tags' - The tag key-value pairs to add to the on-premises instances.
--
-- Keys and values are both required. Keys cannot be null or empty strings.
-- Value-only tags are not allowed.
--
-- 'instanceNames', 'addTagsToOnPremisesInstances_instanceNames' - The names of the on-premises instances to which to add tags.
newAddTagsToOnPremisesInstances ::
  AddTagsToOnPremisesInstances
newAddTagsToOnPremisesInstances :: AddTagsToOnPremisesInstances
newAddTagsToOnPremisesInstances =
  AddTagsToOnPremisesInstances' :: [Tag] -> [Text] -> AddTagsToOnPremisesInstances
AddTagsToOnPremisesInstances'
    { $sel:tags:AddTagsToOnPremisesInstances' :: [Tag]
tags =
        [Tag]
forall a. Monoid a => a
Prelude.mempty,
      $sel:instanceNames:AddTagsToOnPremisesInstances' :: [Text]
instanceNames = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The tag key-value pairs to add to the on-premises instances.
--
-- Keys and values are both required. Keys cannot be null or empty strings.
-- Value-only tags are not allowed.
addTagsToOnPremisesInstances_tags :: Lens.Lens' AddTagsToOnPremisesInstances [Tag]
addTagsToOnPremisesInstances_tags :: ([Tag] -> f [Tag])
-> AddTagsToOnPremisesInstances -> f AddTagsToOnPremisesInstances
addTagsToOnPremisesInstances_tags = (AddTagsToOnPremisesInstances -> [Tag])
-> (AddTagsToOnPremisesInstances
    -> [Tag] -> AddTagsToOnPremisesInstances)
-> Lens
     AddTagsToOnPremisesInstances
     AddTagsToOnPremisesInstances
     [Tag]
     [Tag]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddTagsToOnPremisesInstances' {[Tag]
tags :: [Tag]
$sel:tags:AddTagsToOnPremisesInstances' :: AddTagsToOnPremisesInstances -> [Tag]
tags} -> [Tag]
tags) (\s :: AddTagsToOnPremisesInstances
s@AddTagsToOnPremisesInstances' {} [Tag]
a -> AddTagsToOnPremisesInstances
s {$sel:tags:AddTagsToOnPremisesInstances' :: [Tag]
tags = [Tag]
a} :: AddTagsToOnPremisesInstances) (([Tag] -> f [Tag])
 -> AddTagsToOnPremisesInstances -> f AddTagsToOnPremisesInstances)
-> (([Tag] -> f [Tag]) -> [Tag] -> f [Tag])
-> ([Tag] -> f [Tag])
-> AddTagsToOnPremisesInstances
-> f AddTagsToOnPremisesInstances
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

-- | The names of the on-premises instances to which to add tags.
addTagsToOnPremisesInstances_instanceNames :: Lens.Lens' AddTagsToOnPremisesInstances [Prelude.Text]
addTagsToOnPremisesInstances_instanceNames :: ([Text] -> f [Text])
-> AddTagsToOnPremisesInstances -> f AddTagsToOnPremisesInstances
addTagsToOnPremisesInstances_instanceNames = (AddTagsToOnPremisesInstances -> [Text])
-> (AddTagsToOnPremisesInstances
    -> [Text] -> AddTagsToOnPremisesInstances)
-> Lens
     AddTagsToOnPremisesInstances
     AddTagsToOnPremisesInstances
     [Text]
     [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddTagsToOnPremisesInstances' {[Text]
instanceNames :: [Text]
$sel:instanceNames:AddTagsToOnPremisesInstances' :: AddTagsToOnPremisesInstances -> [Text]
instanceNames} -> [Text]
instanceNames) (\s :: AddTagsToOnPremisesInstances
s@AddTagsToOnPremisesInstances' {} [Text]
a -> AddTagsToOnPremisesInstances
s {$sel:instanceNames:AddTagsToOnPremisesInstances' :: [Text]
instanceNames = [Text]
a} :: AddTagsToOnPremisesInstances) (([Text] -> f [Text])
 -> AddTagsToOnPremisesInstances -> f AddTagsToOnPremisesInstances)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> AddTagsToOnPremisesInstances
-> f AddTagsToOnPremisesInstances
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 AddTagsToOnPremisesInstances where
  type
    AWSResponse AddTagsToOnPremisesInstances =
      AddTagsToOnPremisesInstancesResponse
  request :: AddTagsToOnPremisesInstances
-> Request AddTagsToOnPremisesInstances
request = Service
-> AddTagsToOnPremisesInstances
-> Request AddTagsToOnPremisesInstances
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AddTagsToOnPremisesInstances
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AddTagsToOnPremisesInstances)))
response =
    AWSResponse AddTagsToOnPremisesInstances
-> Logger
-> Service
-> Proxy AddTagsToOnPremisesInstances
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AddTagsToOnPremisesInstances)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse AddTagsToOnPremisesInstances
AddTagsToOnPremisesInstancesResponse
AddTagsToOnPremisesInstancesResponse'

instance
  Prelude.Hashable
    AddTagsToOnPremisesInstances

instance Prelude.NFData AddTagsToOnPremisesInstances

instance Core.ToHeaders AddTagsToOnPremisesInstances where
  toHeaders :: AddTagsToOnPremisesInstances -> [Header]
toHeaders =
    [Header] -> AddTagsToOnPremisesInstances -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"CodeDeploy_20141006.AddTagsToOnPremisesInstances" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

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

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

-- |
-- Create a value of 'AddTagsToOnPremisesInstancesResponse' 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.
newAddTagsToOnPremisesInstancesResponse ::
  AddTagsToOnPremisesInstancesResponse
newAddTagsToOnPremisesInstancesResponse :: AddTagsToOnPremisesInstancesResponse
newAddTagsToOnPremisesInstancesResponse =
  AddTagsToOnPremisesInstancesResponse
AddTagsToOnPremisesInstancesResponse'

instance
  Prelude.NFData
    AddTagsToOnPremisesInstancesResponse