{-# 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.WorkSpacesWeb.AssociateTrustStore
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associates a trust store with a web portal.
module Amazonka.WorkSpacesWeb.AssociateTrustStore
  ( -- * Creating a Request
    AssociateTrustStore (..),
    newAssociateTrustStore,

    -- * Request Lenses
    associateTrustStore_portalArn,
    associateTrustStore_trustStoreArn,

    -- * Destructuring the Response
    AssociateTrustStoreResponse (..),
    newAssociateTrustStoreResponse,

    -- * Response Lenses
    associateTrustStoreResponse_httpStatus,
    associateTrustStoreResponse_portalArn,
    associateTrustStoreResponse_trustStoreArn,
  )
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.WorkSpacesWeb.Types

-- | /See:/ 'newAssociateTrustStore' smart constructor.
data AssociateTrustStore = AssociateTrustStore'
  { -- | The ARN of the web portal.
    AssociateTrustStore -> Text
portalArn :: Prelude.Text,
    -- | The ARN of the trust store.
    AssociateTrustStore -> Text
trustStoreArn :: Prelude.Text
  }
  deriving (AssociateTrustStore -> AssociateTrustStore -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateTrustStore -> AssociateTrustStore -> Bool
$c/= :: AssociateTrustStore -> AssociateTrustStore -> Bool
== :: AssociateTrustStore -> AssociateTrustStore -> Bool
$c== :: AssociateTrustStore -> AssociateTrustStore -> Bool
Prelude.Eq, ReadPrec [AssociateTrustStore]
ReadPrec AssociateTrustStore
Int -> ReadS AssociateTrustStore
ReadS [AssociateTrustStore]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateTrustStore]
$creadListPrec :: ReadPrec [AssociateTrustStore]
readPrec :: ReadPrec AssociateTrustStore
$creadPrec :: ReadPrec AssociateTrustStore
readList :: ReadS [AssociateTrustStore]
$creadList :: ReadS [AssociateTrustStore]
readsPrec :: Int -> ReadS AssociateTrustStore
$creadsPrec :: Int -> ReadS AssociateTrustStore
Prelude.Read, Int -> AssociateTrustStore -> ShowS
[AssociateTrustStore] -> ShowS
AssociateTrustStore -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateTrustStore] -> ShowS
$cshowList :: [AssociateTrustStore] -> ShowS
show :: AssociateTrustStore -> String
$cshow :: AssociateTrustStore -> String
showsPrec :: Int -> AssociateTrustStore -> ShowS
$cshowsPrec :: Int -> AssociateTrustStore -> ShowS
Prelude.Show, forall x. Rep AssociateTrustStore x -> AssociateTrustStore
forall x. AssociateTrustStore -> Rep AssociateTrustStore x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateTrustStore x -> AssociateTrustStore
$cfrom :: forall x. AssociateTrustStore -> Rep AssociateTrustStore x
Prelude.Generic)

-- |
-- Create a value of 'AssociateTrustStore' 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:
--
-- 'portalArn', 'associateTrustStore_portalArn' - The ARN of the web portal.
--
-- 'trustStoreArn', 'associateTrustStore_trustStoreArn' - The ARN of the trust store.
newAssociateTrustStore ::
  -- | 'portalArn'
  Prelude.Text ->
  -- | 'trustStoreArn'
  Prelude.Text ->
  AssociateTrustStore
newAssociateTrustStore :: Text -> Text -> AssociateTrustStore
newAssociateTrustStore Text
pPortalArn_ Text
pTrustStoreArn_ =
  AssociateTrustStore'
    { $sel:portalArn:AssociateTrustStore' :: Text
portalArn = Text
pPortalArn_,
      $sel:trustStoreArn:AssociateTrustStore' :: Text
trustStoreArn = Text
pTrustStoreArn_
    }

-- | The ARN of the web portal.
associateTrustStore_portalArn :: Lens.Lens' AssociateTrustStore Prelude.Text
associateTrustStore_portalArn :: Lens' AssociateTrustStore Text
associateTrustStore_portalArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateTrustStore' {Text
portalArn :: Text
$sel:portalArn:AssociateTrustStore' :: AssociateTrustStore -> Text
portalArn} -> Text
portalArn) (\s :: AssociateTrustStore
s@AssociateTrustStore' {} Text
a -> AssociateTrustStore
s {$sel:portalArn:AssociateTrustStore' :: Text
portalArn = Text
a} :: AssociateTrustStore)

-- | The ARN of the trust store.
associateTrustStore_trustStoreArn :: Lens.Lens' AssociateTrustStore Prelude.Text
associateTrustStore_trustStoreArn :: Lens' AssociateTrustStore Text
associateTrustStore_trustStoreArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateTrustStore' {Text
trustStoreArn :: Text
$sel:trustStoreArn:AssociateTrustStore' :: AssociateTrustStore -> Text
trustStoreArn} -> Text
trustStoreArn) (\s :: AssociateTrustStore
s@AssociateTrustStore' {} Text
a -> AssociateTrustStore
s {$sel:trustStoreArn:AssociateTrustStore' :: Text
trustStoreArn = Text
a} :: AssociateTrustStore)

instance Core.AWSRequest AssociateTrustStore where
  type
    AWSResponse AssociateTrustStore =
      AssociateTrustStoreResponse
  request :: (Service -> Service)
-> AssociateTrustStore -> Request AssociateTrustStore
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AssociateTrustStore
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateTrustStore)))
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 -> Text -> AssociateTrustStoreResponse
AssociateTrustStoreResponse'
            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
"portalArn")
            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
"trustStoreArn")
      )

instance Prelude.Hashable AssociateTrustStore where
  hashWithSalt :: Int -> AssociateTrustStore -> Int
hashWithSalt Int
_salt AssociateTrustStore' {Text
trustStoreArn :: Text
portalArn :: Text
$sel:trustStoreArn:AssociateTrustStore' :: AssociateTrustStore -> Text
$sel:portalArn:AssociateTrustStore' :: AssociateTrustStore -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
portalArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
trustStoreArn

instance Prelude.NFData AssociateTrustStore where
  rnf :: AssociateTrustStore -> ()
rnf AssociateTrustStore' {Text
trustStoreArn :: Text
portalArn :: Text
$sel:trustStoreArn:AssociateTrustStore' :: AssociateTrustStore -> Text
$sel:portalArn:AssociateTrustStore' :: AssociateTrustStore -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
portalArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
trustStoreArn

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

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

instance Data.ToPath AssociateTrustStore where
  toPath :: AssociateTrustStore -> ByteString
toPath AssociateTrustStore' {Text
trustStoreArn :: Text
portalArn :: Text
$sel:trustStoreArn:AssociateTrustStore' :: AssociateTrustStore -> Text
$sel:portalArn:AssociateTrustStore' :: AssociateTrustStore -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/portals/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
portalArn, ByteString
"/trustStores"]

instance Data.ToQuery AssociateTrustStore where
  toQuery :: AssociateTrustStore -> QueryString
toQuery AssociateTrustStore' {Text
trustStoreArn :: Text
portalArn :: Text
$sel:trustStoreArn:AssociateTrustStore' :: AssociateTrustStore -> Text
$sel:portalArn:AssociateTrustStore' :: AssociateTrustStore -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"trustStoreArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
trustStoreArn]

-- | /See:/ 'newAssociateTrustStoreResponse' smart constructor.
data AssociateTrustStoreResponse = AssociateTrustStoreResponse'
  { -- | The response's http status code.
    AssociateTrustStoreResponse -> Int
httpStatus :: Prelude.Int,
    -- | The ARN of the web portal.
    AssociateTrustStoreResponse -> Text
portalArn :: Prelude.Text,
    -- | The ARN of the trust store.
    AssociateTrustStoreResponse -> Text
trustStoreArn :: Prelude.Text
  }
  deriving (AssociateTrustStoreResponse -> AssociateTrustStoreResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateTrustStoreResponse -> AssociateTrustStoreResponse -> Bool
$c/= :: AssociateTrustStoreResponse -> AssociateTrustStoreResponse -> Bool
== :: AssociateTrustStoreResponse -> AssociateTrustStoreResponse -> Bool
$c== :: AssociateTrustStoreResponse -> AssociateTrustStoreResponse -> Bool
Prelude.Eq, ReadPrec [AssociateTrustStoreResponse]
ReadPrec AssociateTrustStoreResponse
Int -> ReadS AssociateTrustStoreResponse
ReadS [AssociateTrustStoreResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateTrustStoreResponse]
$creadListPrec :: ReadPrec [AssociateTrustStoreResponse]
readPrec :: ReadPrec AssociateTrustStoreResponse
$creadPrec :: ReadPrec AssociateTrustStoreResponse
readList :: ReadS [AssociateTrustStoreResponse]
$creadList :: ReadS [AssociateTrustStoreResponse]
readsPrec :: Int -> ReadS AssociateTrustStoreResponse
$creadsPrec :: Int -> ReadS AssociateTrustStoreResponse
Prelude.Read, Int -> AssociateTrustStoreResponse -> ShowS
[AssociateTrustStoreResponse] -> ShowS
AssociateTrustStoreResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateTrustStoreResponse] -> ShowS
$cshowList :: [AssociateTrustStoreResponse] -> ShowS
show :: AssociateTrustStoreResponse -> String
$cshow :: AssociateTrustStoreResponse -> String
showsPrec :: Int -> AssociateTrustStoreResponse -> ShowS
$cshowsPrec :: Int -> AssociateTrustStoreResponse -> ShowS
Prelude.Show, forall x.
Rep AssociateTrustStoreResponse x -> AssociateTrustStoreResponse
forall x.
AssociateTrustStoreResponse -> Rep AssociateTrustStoreResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateTrustStoreResponse x -> AssociateTrustStoreResponse
$cfrom :: forall x.
AssociateTrustStoreResponse -> Rep AssociateTrustStoreResponse x
Prelude.Generic)

-- |
-- Create a value of 'AssociateTrustStoreResponse' 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', 'associateTrustStoreResponse_httpStatus' - The response's http status code.
--
-- 'portalArn', 'associateTrustStoreResponse_portalArn' - The ARN of the web portal.
--
-- 'trustStoreArn', 'associateTrustStoreResponse_trustStoreArn' - The ARN of the trust store.
newAssociateTrustStoreResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'portalArn'
  Prelude.Text ->
  -- | 'trustStoreArn'
  Prelude.Text ->
  AssociateTrustStoreResponse
newAssociateTrustStoreResponse :: Int -> Text -> Text -> AssociateTrustStoreResponse
newAssociateTrustStoreResponse
  Int
pHttpStatus_
  Text
pPortalArn_
  Text
pTrustStoreArn_ =
    AssociateTrustStoreResponse'
      { $sel:httpStatus:AssociateTrustStoreResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:portalArn:AssociateTrustStoreResponse' :: Text
portalArn = Text
pPortalArn_,
        $sel:trustStoreArn:AssociateTrustStoreResponse' :: Text
trustStoreArn = Text
pTrustStoreArn_
      }

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

-- | The ARN of the web portal.
associateTrustStoreResponse_portalArn :: Lens.Lens' AssociateTrustStoreResponse Prelude.Text
associateTrustStoreResponse_portalArn :: Lens' AssociateTrustStoreResponse Text
associateTrustStoreResponse_portalArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateTrustStoreResponse' {Text
portalArn :: Text
$sel:portalArn:AssociateTrustStoreResponse' :: AssociateTrustStoreResponse -> Text
portalArn} -> Text
portalArn) (\s :: AssociateTrustStoreResponse
s@AssociateTrustStoreResponse' {} Text
a -> AssociateTrustStoreResponse
s {$sel:portalArn:AssociateTrustStoreResponse' :: Text
portalArn = Text
a} :: AssociateTrustStoreResponse)

-- | The ARN of the trust store.
associateTrustStoreResponse_trustStoreArn :: Lens.Lens' AssociateTrustStoreResponse Prelude.Text
associateTrustStoreResponse_trustStoreArn :: Lens' AssociateTrustStoreResponse Text
associateTrustStoreResponse_trustStoreArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateTrustStoreResponse' {Text
trustStoreArn :: Text
$sel:trustStoreArn:AssociateTrustStoreResponse' :: AssociateTrustStoreResponse -> Text
trustStoreArn} -> Text
trustStoreArn) (\s :: AssociateTrustStoreResponse
s@AssociateTrustStoreResponse' {} Text
a -> AssociateTrustStoreResponse
s {$sel:trustStoreArn:AssociateTrustStoreResponse' :: Text
trustStoreArn = Text
a} :: AssociateTrustStoreResponse)

instance Prelude.NFData AssociateTrustStoreResponse where
  rnf :: AssociateTrustStoreResponse -> ()
rnf AssociateTrustStoreResponse' {Int
Text
trustStoreArn :: Text
portalArn :: Text
httpStatus :: Int
$sel:trustStoreArn:AssociateTrustStoreResponse' :: AssociateTrustStoreResponse -> Text
$sel:portalArn:AssociateTrustStoreResponse' :: AssociateTrustStoreResponse -> Text
$sel:httpStatus:AssociateTrustStoreResponse' :: AssociateTrustStoreResponse -> 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
portalArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
trustStoreArn