{-# 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.WorkDocs.ActivateUser
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Activates the specified user. Only active users can access Amazon
-- WorkDocs.
module Amazonka.WorkDocs.ActivateUser
  ( -- * Creating a Request
    ActivateUser (..),
    newActivateUser,

    -- * Request Lenses
    activateUser_authenticationToken,
    activateUser_userId,

    -- * Destructuring the Response
    ActivateUserResponse (..),
    newActivateUserResponse,

    -- * Response Lenses
    activateUserResponse_user,
    activateUserResponse_httpStatus,
  )
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.WorkDocs.Types

-- | /See:/ 'newActivateUser' smart constructor.
data ActivateUser = ActivateUser'
  { -- | Amazon WorkDocs authentication token. Not required when using AWS
    -- administrator credentials to access the API.
    ActivateUser -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The ID of the user.
    ActivateUser -> Text
userId :: Prelude.Text
  }
  deriving (ActivateUser -> ActivateUser -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActivateUser -> ActivateUser -> Bool
$c/= :: ActivateUser -> ActivateUser -> Bool
== :: ActivateUser -> ActivateUser -> Bool
$c== :: ActivateUser -> ActivateUser -> Bool
Prelude.Eq, Int -> ActivateUser -> ShowS
[ActivateUser] -> ShowS
ActivateUser -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActivateUser] -> ShowS
$cshowList :: [ActivateUser] -> ShowS
show :: ActivateUser -> String
$cshow :: ActivateUser -> String
showsPrec :: Int -> ActivateUser -> ShowS
$cshowsPrec :: Int -> ActivateUser -> ShowS
Prelude.Show, forall x. Rep ActivateUser x -> ActivateUser
forall x. ActivateUser -> Rep ActivateUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActivateUser x -> ActivateUser
$cfrom :: forall x. ActivateUser -> Rep ActivateUser x
Prelude.Generic)

-- |
-- Create a value of 'ActivateUser' 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:
--
-- 'authenticationToken', 'activateUser_authenticationToken' - Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
--
-- 'userId', 'activateUser_userId' - The ID of the user.
newActivateUser ::
  -- | 'userId'
  Prelude.Text ->
  ActivateUser
newActivateUser :: Text -> ActivateUser
newActivateUser Text
pUserId_ =
  ActivateUser'
    { $sel:authenticationToken:ActivateUser' :: Maybe (Sensitive Text)
authenticationToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:userId:ActivateUser' :: Text
userId = Text
pUserId_
    }

-- | Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
activateUser_authenticationToken :: Lens.Lens' ActivateUser (Prelude.Maybe Prelude.Text)
activateUser_authenticationToken :: Lens' ActivateUser (Maybe Text)
activateUser_authenticationToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivateUser' {Maybe (Sensitive Text)
authenticationToken :: Maybe (Sensitive Text)
$sel:authenticationToken:ActivateUser' :: ActivateUser -> Maybe (Sensitive Text)
authenticationToken} -> Maybe (Sensitive Text)
authenticationToken) (\s :: ActivateUser
s@ActivateUser' {} Maybe (Sensitive Text)
a -> ActivateUser
s {$sel:authenticationToken:ActivateUser' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
a} :: ActivateUser) 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 a. Iso' (Sensitive a) a
Data._Sensitive

-- | The ID of the user.
activateUser_userId :: Lens.Lens' ActivateUser Prelude.Text
activateUser_userId :: Lens' ActivateUser Text
activateUser_userId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivateUser' {Text
userId :: Text
$sel:userId:ActivateUser' :: ActivateUser -> Text
userId} -> Text
userId) (\s :: ActivateUser
s@ActivateUser' {} Text
a -> ActivateUser
s {$sel:userId:ActivateUser' :: Text
userId = Text
a} :: ActivateUser)

instance Core.AWSRequest ActivateUser where
  type AWSResponse ActivateUser = ActivateUserResponse
  request :: (Service -> Service) -> ActivateUser -> Request ActivateUser
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 ActivateUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ActivateUser)))
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 ->
          Maybe User -> Int -> ActivateUserResponse
ActivateUserResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"User")
            forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable ActivateUser where
  hashWithSalt :: Int -> ActivateUser -> Int
hashWithSalt Int
_salt ActivateUser' {Maybe (Sensitive Text)
Text
userId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:userId:ActivateUser' :: ActivateUser -> Text
$sel:authenticationToken:ActivateUser' :: ActivateUser -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
authenticationToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userId

instance Prelude.NFData ActivateUser where
  rnf :: ActivateUser -> ()
rnf ActivateUser' {Maybe (Sensitive Text)
Text
userId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:userId:ActivateUser' :: ActivateUser -> Text
$sel:authenticationToken:ActivateUser' :: ActivateUser -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
authenticationToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userId

instance Data.ToHeaders ActivateUser where
  toHeaders :: ActivateUser -> ResponseHeaders
toHeaders ActivateUser' {Maybe (Sensitive Text)
Text
userId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:userId:ActivateUser' :: ActivateUser -> Text
$sel:authenticationToken:ActivateUser' :: ActivateUser -> Maybe (Sensitive Text)
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"Authentication" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Maybe (Sensitive Text)
authenticationToken,
        HeaderName
"Content-Type"
          forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Data.ToJSON ActivateUser where
  toJSON :: ActivateUser -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath ActivateUser where
  toPath :: ActivateUser -> ByteString
toPath ActivateUser' {Maybe (Sensitive Text)
Text
userId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:userId:ActivateUser' :: ActivateUser -> Text
$sel:authenticationToken:ActivateUser' :: ActivateUser -> Maybe (Sensitive Text)
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/api/v1/users/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
userId, ByteString
"/activation"]

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

-- | /See:/ 'newActivateUserResponse' smart constructor.
data ActivateUserResponse = ActivateUserResponse'
  { -- | The user information.
    ActivateUserResponse -> Maybe User
user :: Prelude.Maybe User,
    -- | The response's http status code.
    ActivateUserResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ActivateUserResponse -> ActivateUserResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActivateUserResponse -> ActivateUserResponse -> Bool
$c/= :: ActivateUserResponse -> ActivateUserResponse -> Bool
== :: ActivateUserResponse -> ActivateUserResponse -> Bool
$c== :: ActivateUserResponse -> ActivateUserResponse -> Bool
Prelude.Eq, Int -> ActivateUserResponse -> ShowS
[ActivateUserResponse] -> ShowS
ActivateUserResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActivateUserResponse] -> ShowS
$cshowList :: [ActivateUserResponse] -> ShowS
show :: ActivateUserResponse -> String
$cshow :: ActivateUserResponse -> String
showsPrec :: Int -> ActivateUserResponse -> ShowS
$cshowsPrec :: Int -> ActivateUserResponse -> ShowS
Prelude.Show, forall x. Rep ActivateUserResponse x -> ActivateUserResponse
forall x. ActivateUserResponse -> Rep ActivateUserResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActivateUserResponse x -> ActivateUserResponse
$cfrom :: forall x. ActivateUserResponse -> Rep ActivateUserResponse x
Prelude.Generic)

-- |
-- Create a value of 'ActivateUserResponse' 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:
--
-- 'user', 'activateUserResponse_user' - The user information.
--
-- 'httpStatus', 'activateUserResponse_httpStatus' - The response's http status code.
newActivateUserResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ActivateUserResponse
newActivateUserResponse :: Int -> ActivateUserResponse
newActivateUserResponse Int
pHttpStatus_ =
  ActivateUserResponse'
    { $sel:user:ActivateUserResponse' :: Maybe User
user = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ActivateUserResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The user information.
activateUserResponse_user :: Lens.Lens' ActivateUserResponse (Prelude.Maybe User)
activateUserResponse_user :: Lens' ActivateUserResponse (Maybe User)
activateUserResponse_user = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivateUserResponse' {Maybe User
user :: Maybe User
$sel:user:ActivateUserResponse' :: ActivateUserResponse -> Maybe User
user} -> Maybe User
user) (\s :: ActivateUserResponse
s@ActivateUserResponse' {} Maybe User
a -> ActivateUserResponse
s {$sel:user:ActivateUserResponse' :: Maybe User
user = Maybe User
a} :: ActivateUserResponse)

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

instance Prelude.NFData ActivateUserResponse where
  rnf :: ActivateUserResponse -> ()
rnf ActivateUserResponse' {Int
Maybe User
httpStatus :: Int
user :: Maybe User
$sel:httpStatus:ActivateUserResponse' :: ActivateUserResponse -> Int
$sel:user:ActivateUserResponse' :: ActivateUserResponse -> Maybe User
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe User
user
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus