{-# 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-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)
--
-- 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.Lens as Lens
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 (Core.Sensitive Prelude.Text),
    -- | The ID of the user.
    ActivateUser -> Text
userId :: Prelude.Text
  }
  deriving (ActivateUser -> ActivateUser -> Bool
(ActivateUser -> ActivateUser -> Bool)
-> (ActivateUser -> ActivateUser -> Bool) -> Eq ActivateUser
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
(Int -> ActivateUser -> ShowS)
-> (ActivateUser -> String)
-> ([ActivateUser] -> ShowS)
-> Show ActivateUser
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. ActivateUser -> Rep ActivateUser x)
-> (forall x. Rep ActivateUser x -> ActivateUser)
-> Generic ActivateUser
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' :: Maybe (Sensitive Text) -> Text -> ActivateUser
ActivateUser'
    { $sel:authenticationToken:ActivateUser' :: Maybe (Sensitive Text)
authenticationToken =
        Maybe (Sensitive Text)
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 :: (Maybe Text -> f (Maybe Text)) -> ActivateUser -> f ActivateUser
activateUser_authenticationToken = (ActivateUser -> Maybe (Sensitive Text))
-> (ActivateUser -> Maybe (Sensitive Text) -> ActivateUser)
-> Lens
     ActivateUser
     ActivateUser
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
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) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> ActivateUser -> f ActivateUser)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> ActivateUser
-> f ActivateUser
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The ID of the user.
activateUser_userId :: Lens.Lens' ActivateUser Prelude.Text
activateUser_userId :: (Text -> f Text) -> ActivateUser -> f ActivateUser
activateUser_userId = (ActivateUser -> Text)
-> (ActivateUser -> Text -> ActivateUser)
-> Lens ActivateUser ActivateUser Text Text
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 :: ActivateUser -> Request ActivateUser
request = Service -> ActivateUser -> Request ActivateUser
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ActivateUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ActivateUser)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ActivateUser))
-> Logger
-> Service
-> Proxy ActivateUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ActivateUser)))
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 ->
          Maybe User -> Int -> ActivateUserResponse
ActivateUserResponse'
            (Maybe User -> Int -> ActivateUserResponse)
-> Either String (Maybe User)
-> Either String (Int -> ActivateUserResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe User)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"User")
            Either String (Int -> ActivateUserResponse)
-> Either String Int -> Either String ActivateUserResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ActivateUser

instance Prelude.NFData ActivateUser

instance Core.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)
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"Authentication" HeaderName -> Maybe (Sensitive Text) -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe (Sensitive Text)
authenticationToken,
        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 ActivateUser where
  toJSON :: ActivateUser -> Value
toJSON = Value -> ActivateUser -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.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)
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/api/v1/users/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
userId, ByteString
"/activation"]

instance Core.ToQuery ActivateUser where
  toQuery :: ActivateUser -> QueryString
toQuery = QueryString -> ActivateUser -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(ActivateUserResponse -> ActivateUserResponse -> Bool)
-> (ActivateUserResponse -> ActivateUserResponse -> Bool)
-> Eq ActivateUserResponse
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, ReadPrec [ActivateUserResponse]
ReadPrec ActivateUserResponse
Int -> ReadS ActivateUserResponse
ReadS [ActivateUserResponse]
(Int -> ReadS ActivateUserResponse)
-> ReadS [ActivateUserResponse]
-> ReadPrec ActivateUserResponse
-> ReadPrec [ActivateUserResponse]
-> Read ActivateUserResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActivateUserResponse]
$creadListPrec :: ReadPrec [ActivateUserResponse]
readPrec :: ReadPrec ActivateUserResponse
$creadPrec :: ReadPrec ActivateUserResponse
readList :: ReadS [ActivateUserResponse]
$creadList :: ReadS [ActivateUserResponse]
readsPrec :: Int -> ReadS ActivateUserResponse
$creadsPrec :: Int -> ReadS ActivateUserResponse
Prelude.Read, Int -> ActivateUserResponse -> ShowS
[ActivateUserResponse] -> ShowS
ActivateUserResponse -> String
(Int -> ActivateUserResponse -> ShowS)
-> (ActivateUserResponse -> String)
-> ([ActivateUserResponse] -> ShowS)
-> Show ActivateUserResponse
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. ActivateUserResponse -> Rep ActivateUserResponse x)
-> (forall x. Rep ActivateUserResponse x -> ActivateUserResponse)
-> Generic ActivateUserResponse
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' :: Maybe User -> Int -> ActivateUserResponse
ActivateUserResponse'
    { $sel:user:ActivateUserResponse' :: Maybe User
user = Maybe 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 :: (Maybe User -> f (Maybe User))
-> ActivateUserResponse -> f ActivateUserResponse
activateUserResponse_user = (ActivateUserResponse -> Maybe User)
-> (ActivateUserResponse -> Maybe User -> ActivateUserResponse)
-> Lens
     ActivateUserResponse ActivateUserResponse (Maybe User) (Maybe 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 :: (Int -> f Int) -> ActivateUserResponse -> f ActivateUserResponse
activateUserResponse_httpStatus = (ActivateUserResponse -> Int)
-> (ActivateUserResponse -> Int -> ActivateUserResponse)
-> Lens ActivateUserResponse ActivateUserResponse Int Int
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