{-# 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.WellArchitected.AssociateLenses
-- 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)
--
-- Associate a lens to a workload.
module Amazonka.WellArchitected.AssociateLenses
  ( -- * Creating a Request
    AssociateLenses (..),
    newAssociateLenses,

    -- * Request Lenses
    associateLenses_workloadId,
    associateLenses_lensAliases,

    -- * Destructuring the Response
    AssociateLensesResponse (..),
    newAssociateLensesResponse,
  )
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 qualified Amazonka.Response as Response
import Amazonka.WellArchitected.Types

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

-- |
-- Create a value of 'AssociateLenses' 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:
--
-- 'workloadId', 'associateLenses_workloadId' - Undocumented member.
--
-- 'lensAliases', 'associateLenses_lensAliases' - Undocumented member.
newAssociateLenses ::
  -- | 'workloadId'
  Prelude.Text ->
  -- | 'lensAliases'
  Prelude.NonEmpty Prelude.Text ->
  AssociateLenses
newAssociateLenses :: Text -> NonEmpty Text -> AssociateLenses
newAssociateLenses Text
pWorkloadId_ NonEmpty Text
pLensAliases_ =
  AssociateLenses' :: Text -> NonEmpty Text -> AssociateLenses
AssociateLenses'
    { $sel:workloadId:AssociateLenses' :: Text
workloadId = Text
pWorkloadId_,
      $sel:lensAliases:AssociateLenses' :: NonEmpty Text
lensAliases = 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
pLensAliases_
    }

-- | Undocumented member.
associateLenses_workloadId :: Lens.Lens' AssociateLenses Prelude.Text
associateLenses_workloadId :: (Text -> f Text) -> AssociateLenses -> f AssociateLenses
associateLenses_workloadId = (AssociateLenses -> Text)
-> (AssociateLenses -> Text -> AssociateLenses)
-> Lens AssociateLenses AssociateLenses Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateLenses' {Text
workloadId :: Text
$sel:workloadId:AssociateLenses' :: AssociateLenses -> Text
workloadId} -> Text
workloadId) (\s :: AssociateLenses
s@AssociateLenses' {} Text
a -> AssociateLenses
s {$sel:workloadId:AssociateLenses' :: Text
workloadId = Text
a} :: AssociateLenses)

-- | Undocumented member.
associateLenses_lensAliases :: Lens.Lens' AssociateLenses (Prelude.NonEmpty Prelude.Text)
associateLenses_lensAliases :: (NonEmpty Text -> f (NonEmpty Text))
-> AssociateLenses -> f AssociateLenses
associateLenses_lensAliases = (AssociateLenses -> NonEmpty Text)
-> (AssociateLenses -> NonEmpty Text -> AssociateLenses)
-> Lens
     AssociateLenses AssociateLenses (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateLenses' {NonEmpty Text
lensAliases :: NonEmpty Text
$sel:lensAliases:AssociateLenses' :: AssociateLenses -> NonEmpty Text
lensAliases} -> NonEmpty Text
lensAliases) (\s :: AssociateLenses
s@AssociateLenses' {} NonEmpty Text
a -> AssociateLenses
s {$sel:lensAliases:AssociateLenses' :: NonEmpty Text
lensAliases = NonEmpty Text
a} :: AssociateLenses) ((NonEmpty Text -> f (NonEmpty Text))
 -> AssociateLenses -> f AssociateLenses)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> AssociateLenses
-> f AssociateLenses
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

instance Core.AWSRequest AssociateLenses where
  type
    AWSResponse AssociateLenses =
      AssociateLensesResponse
  request :: AssociateLenses -> Request AssociateLenses
request = Service -> AssociateLenses -> Request AssociateLenses
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateLenses
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AssociateLenses)))
response =
    AWSResponse AssociateLenses
-> Logger
-> Service
-> Proxy AssociateLenses
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AssociateLenses)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse AssociateLenses
AssociateLensesResponse
AssociateLensesResponse'

instance Prelude.Hashable AssociateLenses

instance Prelude.NFData AssociateLenses

instance Core.ToHeaders AssociateLenses where
  toHeaders :: AssociateLenses -> [Header]
toHeaders =
    [Header] -> AssociateLenses -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 AssociateLenses where
  toJSON :: AssociateLenses -> Value
toJSON AssociateLenses' {NonEmpty Text
Text
lensAliases :: NonEmpty Text
workloadId :: Text
$sel:lensAliases:AssociateLenses' :: AssociateLenses -> NonEmpty Text
$sel:workloadId:AssociateLenses' :: AssociateLenses -> 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
"LensAliases" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
lensAliases)]
      )

instance Core.ToPath AssociateLenses where
  toPath :: AssociateLenses -> ByteString
toPath AssociateLenses' {NonEmpty Text
Text
lensAliases :: NonEmpty Text
workloadId :: Text
$sel:lensAliases:AssociateLenses' :: AssociateLenses -> NonEmpty Text
$sel:workloadId:AssociateLenses' :: AssociateLenses -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/workloads/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
workloadId,
        ByteString
"/associateLenses"
      ]

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

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

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

instance Prelude.NFData AssociateLensesResponse