{-# 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.Transfer.UpdateProfile
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates some of the parameters for an existing profile. Provide the
-- @ProfileId@ for the profile that you want to update, along with the new
-- values for the parameters to update.
module Amazonka.Transfer.UpdateProfile
  ( -- * Creating a Request
    UpdateProfile (..),
    newUpdateProfile,

    -- * Request Lenses
    updateProfile_certificateIds,
    updateProfile_profileId,

    -- * Destructuring the Response
    UpdateProfileResponse (..),
    newUpdateProfileResponse,

    -- * Response Lenses
    updateProfileResponse_httpStatus,
    updateProfileResponse_profileId,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Transfer.Types

-- | /See:/ 'newUpdateProfile' smart constructor.
data UpdateProfile = UpdateProfile'
  { -- | An array of identifiers for the imported certificates. You use this
    -- identifier for working with profiles and partner profiles.
    UpdateProfile -> Maybe [Text]
certificateIds :: Prelude.Maybe [Prelude.Text],
    -- | The identifier of the profile object that you are updating.
    UpdateProfile -> Text
profileId :: Prelude.Text
  }
  deriving (UpdateProfile -> UpdateProfile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateProfile -> UpdateProfile -> Bool
$c/= :: UpdateProfile -> UpdateProfile -> Bool
== :: UpdateProfile -> UpdateProfile -> Bool
$c== :: UpdateProfile -> UpdateProfile -> Bool
Prelude.Eq, ReadPrec [UpdateProfile]
ReadPrec UpdateProfile
Int -> ReadS UpdateProfile
ReadS [UpdateProfile]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateProfile]
$creadListPrec :: ReadPrec [UpdateProfile]
readPrec :: ReadPrec UpdateProfile
$creadPrec :: ReadPrec UpdateProfile
readList :: ReadS [UpdateProfile]
$creadList :: ReadS [UpdateProfile]
readsPrec :: Int -> ReadS UpdateProfile
$creadsPrec :: Int -> ReadS UpdateProfile
Prelude.Read, Int -> UpdateProfile -> ShowS
[UpdateProfile] -> ShowS
UpdateProfile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateProfile] -> ShowS
$cshowList :: [UpdateProfile] -> ShowS
show :: UpdateProfile -> String
$cshow :: UpdateProfile -> String
showsPrec :: Int -> UpdateProfile -> ShowS
$cshowsPrec :: Int -> UpdateProfile -> ShowS
Prelude.Show, forall x. Rep UpdateProfile x -> UpdateProfile
forall x. UpdateProfile -> Rep UpdateProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateProfile x -> UpdateProfile
$cfrom :: forall x. UpdateProfile -> Rep UpdateProfile x
Prelude.Generic)

-- |
-- Create a value of 'UpdateProfile' 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:
--
-- 'certificateIds', 'updateProfile_certificateIds' - An array of identifiers for the imported certificates. You use this
-- identifier for working with profiles and partner profiles.
--
-- 'profileId', 'updateProfile_profileId' - The identifier of the profile object that you are updating.
newUpdateProfile ::
  -- | 'profileId'
  Prelude.Text ->
  UpdateProfile
newUpdateProfile :: Text -> UpdateProfile
newUpdateProfile Text
pProfileId_ =
  UpdateProfile'
    { $sel:certificateIds:UpdateProfile' :: Maybe [Text]
certificateIds = forall a. Maybe a
Prelude.Nothing,
      $sel:profileId:UpdateProfile' :: Text
profileId = Text
pProfileId_
    }

-- | An array of identifiers for the imported certificates. You use this
-- identifier for working with profiles and partner profiles.
updateProfile_certificateIds :: Lens.Lens' UpdateProfile (Prelude.Maybe [Prelude.Text])
updateProfile_certificateIds :: Lens' UpdateProfile (Maybe [Text])
updateProfile_certificateIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProfile' {Maybe [Text]
certificateIds :: Maybe [Text]
$sel:certificateIds:UpdateProfile' :: UpdateProfile -> Maybe [Text]
certificateIds} -> Maybe [Text]
certificateIds) (\s :: UpdateProfile
s@UpdateProfile' {} Maybe [Text]
a -> UpdateProfile
s {$sel:certificateIds:UpdateProfile' :: Maybe [Text]
certificateIds = Maybe [Text]
a} :: UpdateProfile) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The identifier of the profile object that you are updating.
updateProfile_profileId :: Lens.Lens' UpdateProfile Prelude.Text
updateProfile_profileId :: Lens' UpdateProfile Text
updateProfile_profileId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProfile' {Text
profileId :: Text
$sel:profileId:UpdateProfile' :: UpdateProfile -> Text
profileId} -> Text
profileId) (\s :: UpdateProfile
s@UpdateProfile' {} Text
a -> UpdateProfile
s {$sel:profileId:UpdateProfile' :: Text
profileId = Text
a} :: UpdateProfile)

instance Core.AWSRequest UpdateProfile where
  type
    AWSResponse UpdateProfile =
      UpdateProfileResponse
  request :: (Service -> Service) -> UpdateProfile -> Request UpdateProfile
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateProfile
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateProfile)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Text -> UpdateProfileResponse
UpdateProfileResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"ProfileId")
      )

instance Prelude.Hashable UpdateProfile where
  hashWithSalt :: Int -> UpdateProfile -> Int
hashWithSalt Int
_salt UpdateProfile' {Maybe [Text]
Text
profileId :: Text
certificateIds :: Maybe [Text]
$sel:profileId:UpdateProfile' :: UpdateProfile -> Text
$sel:certificateIds:UpdateProfile' :: UpdateProfile -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
certificateIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
profileId

instance Prelude.NFData UpdateProfile where
  rnf :: UpdateProfile -> ()
rnf UpdateProfile' {Maybe [Text]
Text
profileId :: Text
certificateIds :: Maybe [Text]
$sel:profileId:UpdateProfile' :: UpdateProfile -> Text
$sel:certificateIds:UpdateProfile' :: UpdateProfile -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
certificateIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
profileId

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

instance Data.ToJSON UpdateProfile where
  toJSON :: UpdateProfile -> Value
toJSON UpdateProfile' {Maybe [Text]
Text
profileId :: Text
certificateIds :: Maybe [Text]
$sel:profileId:UpdateProfile' :: UpdateProfile -> Text
$sel:certificateIds:UpdateProfile' :: UpdateProfile -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CertificateIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
certificateIds,
            forall a. a -> Maybe a
Prelude.Just (Key
"ProfileId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
profileId)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateProfileResponse' 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', 'updateProfileResponse_httpStatus' - The response's http status code.
--
-- 'profileId', 'updateProfileResponse_profileId' - Returns the identifier for the profile that\'s being updated.
newUpdateProfileResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'profileId'
  Prelude.Text ->
  UpdateProfileResponse
newUpdateProfileResponse :: Int -> Text -> UpdateProfileResponse
newUpdateProfileResponse Int
pHttpStatus_ Text
pProfileId_ =
  UpdateProfileResponse'
    { $sel:httpStatus:UpdateProfileResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:profileId:UpdateProfileResponse' :: Text
profileId = Text
pProfileId_
    }

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

-- | Returns the identifier for the profile that\'s being updated.
updateProfileResponse_profileId :: Lens.Lens' UpdateProfileResponse Prelude.Text
updateProfileResponse_profileId :: Lens' UpdateProfileResponse Text
updateProfileResponse_profileId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProfileResponse' {Text
profileId :: Text
$sel:profileId:UpdateProfileResponse' :: UpdateProfileResponse -> Text
profileId} -> Text
profileId) (\s :: UpdateProfileResponse
s@UpdateProfileResponse' {} Text
a -> UpdateProfileResponse
s {$sel:profileId:UpdateProfileResponse' :: Text
profileId = Text
a} :: UpdateProfileResponse)

instance Prelude.NFData UpdateProfileResponse where
  rnf :: UpdateProfileResponse -> ()
rnf UpdateProfileResponse' {Int
Text
profileId :: Text
httpStatus :: Int
$sel:profileId:UpdateProfileResponse' :: UpdateProfileResponse -> Text
$sel:httpStatus:UpdateProfileResponse' :: UpdateProfileResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
profileId