{-# 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.AppConfig.UpdateConfigurationProfile
-- 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)
--
-- Updates a configuration profile.
module Amazonka.AppConfig.UpdateConfigurationProfile
  ( -- * Creating a Request
    UpdateConfigurationProfile (..),
    newUpdateConfigurationProfile,

    -- * Request Lenses
    updateConfigurationProfile_retrievalRoleArn,
    updateConfigurationProfile_validators,
    updateConfigurationProfile_name,
    updateConfigurationProfile_description,
    updateConfigurationProfile_applicationId,
    updateConfigurationProfile_configurationProfileId,

    -- * Destructuring the Response
    ConfigurationProfile (..),
    newConfigurationProfile,

    -- * Response Lenses
    configurationProfile_retrievalRoleArn,
    configurationProfile_validators,
    configurationProfile_locationUri,
    configurationProfile_applicationId,
    configurationProfile_name,
    configurationProfile_id,
    configurationProfile_description,
  )
where

import Amazonka.AppConfig.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

-- | /See:/ 'newUpdateConfigurationProfile' smart constructor.
data UpdateConfigurationProfile = UpdateConfigurationProfile'
  { -- | The ARN of an IAM role with permission to access the configuration at
    -- the specified LocationUri.
    UpdateConfigurationProfile -> Maybe Text
retrievalRoleArn :: Prelude.Maybe Prelude.Text,
    -- | A list of methods for validating the configuration.
    UpdateConfigurationProfile -> Maybe [Validator]
validators :: Prelude.Maybe [Validator],
    -- | The name of the configuration profile.
    UpdateConfigurationProfile -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A description of the configuration profile.
    UpdateConfigurationProfile -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The application ID.
    UpdateConfigurationProfile -> Text
applicationId :: Prelude.Text,
    -- | The ID of the configuration profile.
    UpdateConfigurationProfile -> Text
configurationProfileId :: Prelude.Text
  }
  deriving (UpdateConfigurationProfile -> UpdateConfigurationProfile -> Bool
(UpdateConfigurationProfile -> UpdateConfigurationProfile -> Bool)
-> (UpdateConfigurationProfile
    -> UpdateConfigurationProfile -> Bool)
-> Eq UpdateConfigurationProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateConfigurationProfile -> UpdateConfigurationProfile -> Bool
$c/= :: UpdateConfigurationProfile -> UpdateConfigurationProfile -> Bool
== :: UpdateConfigurationProfile -> UpdateConfigurationProfile -> Bool
$c== :: UpdateConfigurationProfile -> UpdateConfigurationProfile -> Bool
Prelude.Eq, Int -> UpdateConfigurationProfile -> ShowS
[UpdateConfigurationProfile] -> ShowS
UpdateConfigurationProfile -> String
(Int -> UpdateConfigurationProfile -> ShowS)
-> (UpdateConfigurationProfile -> String)
-> ([UpdateConfigurationProfile] -> ShowS)
-> Show UpdateConfigurationProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateConfigurationProfile] -> ShowS
$cshowList :: [UpdateConfigurationProfile] -> ShowS
show :: UpdateConfigurationProfile -> String
$cshow :: UpdateConfigurationProfile -> String
showsPrec :: Int -> UpdateConfigurationProfile -> ShowS
$cshowsPrec :: Int -> UpdateConfigurationProfile -> ShowS
Prelude.Show, (forall x.
 UpdateConfigurationProfile -> Rep UpdateConfigurationProfile x)
-> (forall x.
    Rep UpdateConfigurationProfile x -> UpdateConfigurationProfile)
-> Generic UpdateConfigurationProfile
forall x.
Rep UpdateConfigurationProfile x -> UpdateConfigurationProfile
forall x.
UpdateConfigurationProfile -> Rep UpdateConfigurationProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateConfigurationProfile x -> UpdateConfigurationProfile
$cfrom :: forall x.
UpdateConfigurationProfile -> Rep UpdateConfigurationProfile x
Prelude.Generic)

-- |
-- Create a value of 'UpdateConfigurationProfile' 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:
--
-- 'retrievalRoleArn', 'updateConfigurationProfile_retrievalRoleArn' - The ARN of an IAM role with permission to access the configuration at
-- the specified LocationUri.
--
-- 'validators', 'updateConfigurationProfile_validators' - A list of methods for validating the configuration.
--
-- 'name', 'updateConfigurationProfile_name' - The name of the configuration profile.
--
-- 'description', 'updateConfigurationProfile_description' - A description of the configuration profile.
--
-- 'applicationId', 'updateConfigurationProfile_applicationId' - The application ID.
--
-- 'configurationProfileId', 'updateConfigurationProfile_configurationProfileId' - The ID of the configuration profile.
newUpdateConfigurationProfile ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'configurationProfileId'
  Prelude.Text ->
  UpdateConfigurationProfile
newUpdateConfigurationProfile :: Text -> Text -> UpdateConfigurationProfile
newUpdateConfigurationProfile
  Text
pApplicationId_
  Text
pConfigurationProfileId_ =
    UpdateConfigurationProfile' :: Maybe Text
-> Maybe [Validator]
-> Maybe Text
-> Maybe Text
-> Text
-> Text
-> UpdateConfigurationProfile
UpdateConfigurationProfile'
      { $sel:retrievalRoleArn:UpdateConfigurationProfile' :: Maybe Text
retrievalRoleArn =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:validators:UpdateConfigurationProfile' :: Maybe [Validator]
validators = Maybe [Validator]
forall a. Maybe a
Prelude.Nothing,
        $sel:name:UpdateConfigurationProfile' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:description:UpdateConfigurationProfile' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:applicationId:UpdateConfigurationProfile' :: Text
applicationId = Text
pApplicationId_,
        $sel:configurationProfileId:UpdateConfigurationProfile' :: Text
configurationProfileId =
          Text
pConfigurationProfileId_
      }

-- | The ARN of an IAM role with permission to access the configuration at
-- the specified LocationUri.
updateConfigurationProfile_retrievalRoleArn :: Lens.Lens' UpdateConfigurationProfile (Prelude.Maybe Prelude.Text)
updateConfigurationProfile_retrievalRoleArn :: (Maybe Text -> f (Maybe Text))
-> UpdateConfigurationProfile -> f UpdateConfigurationProfile
updateConfigurationProfile_retrievalRoleArn = (UpdateConfigurationProfile -> Maybe Text)
-> (UpdateConfigurationProfile
    -> Maybe Text -> UpdateConfigurationProfile)
-> Lens
     UpdateConfigurationProfile
     UpdateConfigurationProfile
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConfigurationProfile' {Maybe Text
retrievalRoleArn :: Maybe Text
$sel:retrievalRoleArn:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Maybe Text
retrievalRoleArn} -> Maybe Text
retrievalRoleArn) (\s :: UpdateConfigurationProfile
s@UpdateConfigurationProfile' {} Maybe Text
a -> UpdateConfigurationProfile
s {$sel:retrievalRoleArn:UpdateConfigurationProfile' :: Maybe Text
retrievalRoleArn = Maybe Text
a} :: UpdateConfigurationProfile)

-- | A list of methods for validating the configuration.
updateConfigurationProfile_validators :: Lens.Lens' UpdateConfigurationProfile (Prelude.Maybe [Validator])
updateConfigurationProfile_validators :: (Maybe [Validator] -> f (Maybe [Validator]))
-> UpdateConfigurationProfile -> f UpdateConfigurationProfile
updateConfigurationProfile_validators = (UpdateConfigurationProfile -> Maybe [Validator])
-> (UpdateConfigurationProfile
    -> Maybe [Validator] -> UpdateConfigurationProfile)
-> Lens
     UpdateConfigurationProfile
     UpdateConfigurationProfile
     (Maybe [Validator])
     (Maybe [Validator])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConfigurationProfile' {Maybe [Validator]
validators :: Maybe [Validator]
$sel:validators:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Maybe [Validator]
validators} -> Maybe [Validator]
validators) (\s :: UpdateConfigurationProfile
s@UpdateConfigurationProfile' {} Maybe [Validator]
a -> UpdateConfigurationProfile
s {$sel:validators:UpdateConfigurationProfile' :: Maybe [Validator]
validators = Maybe [Validator]
a} :: UpdateConfigurationProfile) ((Maybe [Validator] -> f (Maybe [Validator]))
 -> UpdateConfigurationProfile -> f UpdateConfigurationProfile)
-> ((Maybe [Validator] -> f (Maybe [Validator]))
    -> Maybe [Validator] -> f (Maybe [Validator]))
-> (Maybe [Validator] -> f (Maybe [Validator]))
-> UpdateConfigurationProfile
-> f UpdateConfigurationProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Validator] [Validator] [Validator] [Validator]
-> Iso
     (Maybe [Validator])
     (Maybe [Validator])
     (Maybe [Validator])
     (Maybe [Validator])
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 [Validator] [Validator] [Validator] [Validator]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the configuration profile.
updateConfigurationProfile_name :: Lens.Lens' UpdateConfigurationProfile (Prelude.Maybe Prelude.Text)
updateConfigurationProfile_name :: (Maybe Text -> f (Maybe Text))
-> UpdateConfigurationProfile -> f UpdateConfigurationProfile
updateConfigurationProfile_name = (UpdateConfigurationProfile -> Maybe Text)
-> (UpdateConfigurationProfile
    -> Maybe Text -> UpdateConfigurationProfile)
-> Lens
     UpdateConfigurationProfile
     UpdateConfigurationProfile
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConfigurationProfile' {Maybe Text
name :: Maybe Text
$sel:name:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateConfigurationProfile
s@UpdateConfigurationProfile' {} Maybe Text
a -> UpdateConfigurationProfile
s {$sel:name:UpdateConfigurationProfile' :: Maybe Text
name = Maybe Text
a} :: UpdateConfigurationProfile)

-- | A description of the configuration profile.
updateConfigurationProfile_description :: Lens.Lens' UpdateConfigurationProfile (Prelude.Maybe Prelude.Text)
updateConfigurationProfile_description :: (Maybe Text -> f (Maybe Text))
-> UpdateConfigurationProfile -> f UpdateConfigurationProfile
updateConfigurationProfile_description = (UpdateConfigurationProfile -> Maybe Text)
-> (UpdateConfigurationProfile
    -> Maybe Text -> UpdateConfigurationProfile)
-> Lens
     UpdateConfigurationProfile
     UpdateConfigurationProfile
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConfigurationProfile' {Maybe Text
description :: Maybe Text
$sel:description:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateConfigurationProfile
s@UpdateConfigurationProfile' {} Maybe Text
a -> UpdateConfigurationProfile
s {$sel:description:UpdateConfigurationProfile' :: Maybe Text
description = Maybe Text
a} :: UpdateConfigurationProfile)

-- | The application ID.
updateConfigurationProfile_applicationId :: Lens.Lens' UpdateConfigurationProfile Prelude.Text
updateConfigurationProfile_applicationId :: (Text -> f Text)
-> UpdateConfigurationProfile -> f UpdateConfigurationProfile
updateConfigurationProfile_applicationId = (UpdateConfigurationProfile -> Text)
-> (UpdateConfigurationProfile
    -> Text -> UpdateConfigurationProfile)
-> Lens
     UpdateConfigurationProfile UpdateConfigurationProfile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConfigurationProfile' {Text
applicationId :: Text
$sel:applicationId:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Text
applicationId} -> Text
applicationId) (\s :: UpdateConfigurationProfile
s@UpdateConfigurationProfile' {} Text
a -> UpdateConfigurationProfile
s {$sel:applicationId:UpdateConfigurationProfile' :: Text
applicationId = Text
a} :: UpdateConfigurationProfile)

-- | The ID of the configuration profile.
updateConfigurationProfile_configurationProfileId :: Lens.Lens' UpdateConfigurationProfile Prelude.Text
updateConfigurationProfile_configurationProfileId :: (Text -> f Text)
-> UpdateConfigurationProfile -> f UpdateConfigurationProfile
updateConfigurationProfile_configurationProfileId = (UpdateConfigurationProfile -> Text)
-> (UpdateConfigurationProfile
    -> Text -> UpdateConfigurationProfile)
-> Lens
     UpdateConfigurationProfile UpdateConfigurationProfile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConfigurationProfile' {Text
configurationProfileId :: Text
$sel:configurationProfileId:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Text
configurationProfileId} -> Text
configurationProfileId) (\s :: UpdateConfigurationProfile
s@UpdateConfigurationProfile' {} Text
a -> UpdateConfigurationProfile
s {$sel:configurationProfileId:UpdateConfigurationProfile' :: Text
configurationProfileId = Text
a} :: UpdateConfigurationProfile)

instance Core.AWSRequest UpdateConfigurationProfile where
  type
    AWSResponse UpdateConfigurationProfile =
      ConfigurationProfile
  request :: UpdateConfigurationProfile -> Request UpdateConfigurationProfile
request = Service
-> UpdateConfigurationProfile -> Request UpdateConfigurationProfile
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateConfigurationProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateConfigurationProfile)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateConfigurationProfile))
-> Logger
-> Service
-> Proxy UpdateConfigurationProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateConfigurationProfile)))
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 -> Object -> Either String ConfigurationProfile
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable UpdateConfigurationProfile

instance Prelude.NFData UpdateConfigurationProfile

instance Core.ToHeaders UpdateConfigurationProfile where
  toHeaders :: UpdateConfigurationProfile -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateConfigurationProfile -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 UpdateConfigurationProfile where
  toJSON :: UpdateConfigurationProfile -> Value
toJSON UpdateConfigurationProfile' {Maybe [Validator]
Maybe Text
Text
configurationProfileId :: Text
applicationId :: Text
description :: Maybe Text
name :: Maybe Text
validators :: Maybe [Validator]
retrievalRoleArn :: Maybe Text
$sel:configurationProfileId:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Text
$sel:applicationId:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Text
$sel:description:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Maybe Text
$sel:name:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Maybe Text
$sel:validators:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Maybe [Validator]
$sel:retrievalRoleArn:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RetrievalRoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
retrievalRoleArn,
            (Text
"Validators" Text -> [Validator] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Validator] -> Pair) -> Maybe [Validator] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Validator]
validators,
            (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description
          ]
      )

instance Core.ToPath UpdateConfigurationProfile where
  toPath :: UpdateConfigurationProfile -> ByteString
toPath UpdateConfigurationProfile' {Maybe [Validator]
Maybe Text
Text
configurationProfileId :: Text
applicationId :: Text
description :: Maybe Text
name :: Maybe Text
validators :: Maybe [Validator]
retrievalRoleArn :: Maybe Text
$sel:configurationProfileId:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Text
$sel:applicationId:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Text
$sel:description:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Maybe Text
$sel:name:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Maybe Text
$sel:validators:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Maybe [Validator]
$sel:retrievalRoleArn:UpdateConfigurationProfile' :: UpdateConfigurationProfile -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/applications/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId,
        ByteString
"/configurationprofiles/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
configurationProfileId
      ]

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