{-# 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.CreateTrustStore
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a trust store that can be associated with a web portal. A trust
-- store contains certificate authority (CA) certificates. Once associated
-- with a web portal, the browser in a streaming session will recognize
-- certificates that have been issued using any of the CAs in the trust
-- store. If your organization has internal websites that use certificates
-- issued by private CAs, you should add the private CA certificate to the
-- trust store.
module Amazonka.WorkSpacesWeb.CreateTrustStore
  ( -- * Creating a Request
    CreateTrustStore (..),
    newCreateTrustStore,

    -- * Request Lenses
    createTrustStore_clientToken,
    createTrustStore_tags,
    createTrustStore_certificateList,

    -- * Destructuring the Response
    CreateTrustStoreResponse (..),
    newCreateTrustStoreResponse,

    -- * Response Lenses
    createTrustStoreResponse_httpStatus,
    createTrustStoreResponse_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:/ 'newCreateTrustStore' smart constructor.
data CreateTrustStore = CreateTrustStore'
  { -- | A unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request. Idempotency ensures that an API request
    -- completes only once. With an idempotent request, if the original request
    -- completes successfully, subsequent retries with the same client token
    -- returns the result from the original successful request.
    --
    -- If you do not specify a client token, one is automatically generated by
    -- the AWS SDK.
    CreateTrustStore -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The tags to add to the trust store. A tag is a key-value pair.
    CreateTrustStore -> Maybe [Sensitive Tag]
tags :: Prelude.Maybe [Data.Sensitive Tag],
    -- | A list of CA certificates to be added to the trust store.
    CreateTrustStore -> [Base64]
certificateList :: [Data.Base64]
  }
  deriving (CreateTrustStore -> CreateTrustStore -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTrustStore -> CreateTrustStore -> Bool
$c/= :: CreateTrustStore -> CreateTrustStore -> Bool
== :: CreateTrustStore -> CreateTrustStore -> Bool
$c== :: CreateTrustStore -> CreateTrustStore -> Bool
Prelude.Eq, Int -> CreateTrustStore -> ShowS
[CreateTrustStore] -> ShowS
CreateTrustStore -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTrustStore] -> ShowS
$cshowList :: [CreateTrustStore] -> ShowS
show :: CreateTrustStore -> String
$cshow :: CreateTrustStore -> String
showsPrec :: Int -> CreateTrustStore -> ShowS
$cshowsPrec :: Int -> CreateTrustStore -> ShowS
Prelude.Show, forall x. Rep CreateTrustStore x -> CreateTrustStore
forall x. CreateTrustStore -> Rep CreateTrustStore x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTrustStore x -> CreateTrustStore
$cfrom :: forall x. CreateTrustStore -> Rep CreateTrustStore x
Prelude.Generic)

-- |
-- Create a value of 'CreateTrustStore' 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:
--
-- 'clientToken', 'createTrustStore_clientToken' - A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. Idempotency ensures that an API request
-- completes only once. With an idempotent request, if the original request
-- completes successfully, subsequent retries with the same client token
-- returns the result from the original successful request.
--
-- If you do not specify a client token, one is automatically generated by
-- the AWS SDK.
--
-- 'tags', 'createTrustStore_tags' - The tags to add to the trust store. A tag is a key-value pair.
--
-- 'certificateList', 'createTrustStore_certificateList' - A list of CA certificates to be added to the trust store.
newCreateTrustStore ::
  CreateTrustStore
newCreateTrustStore :: CreateTrustStore
newCreateTrustStore =
  CreateTrustStore'
    { $sel:clientToken:CreateTrustStore' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateTrustStore' :: Maybe [Sensitive Tag]
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:certificateList:CreateTrustStore' :: [Base64]
certificateList = forall a. Monoid a => a
Prelude.mempty
    }

-- | A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. Idempotency ensures that an API request
-- completes only once. With an idempotent request, if the original request
-- completes successfully, subsequent retries with the same client token
-- returns the result from the original successful request.
--
-- If you do not specify a client token, one is automatically generated by
-- the AWS SDK.
createTrustStore_clientToken :: Lens.Lens' CreateTrustStore (Prelude.Maybe Prelude.Text)
createTrustStore_clientToken :: Lens' CreateTrustStore (Maybe Text)
createTrustStore_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrustStore' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateTrustStore' :: CreateTrustStore -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateTrustStore
s@CreateTrustStore' {} Maybe Text
a -> CreateTrustStore
s {$sel:clientToken:CreateTrustStore' :: Maybe Text
clientToken = Maybe Text
a} :: CreateTrustStore)

-- | The tags to add to the trust store. A tag is a key-value pair.
createTrustStore_tags :: Lens.Lens' CreateTrustStore (Prelude.Maybe [Tag])
createTrustStore_tags :: Lens' CreateTrustStore (Maybe [Tag])
createTrustStore_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrustStore' {Maybe [Sensitive Tag]
tags :: Maybe [Sensitive Tag]
$sel:tags:CreateTrustStore' :: CreateTrustStore -> Maybe [Sensitive Tag]
tags} -> Maybe [Sensitive Tag]
tags) (\s :: CreateTrustStore
s@CreateTrustStore' {} Maybe [Sensitive Tag]
a -> CreateTrustStore
s {$sel:tags:CreateTrustStore' :: Maybe [Sensitive Tag]
tags = Maybe [Sensitive Tag]
a} :: CreateTrustStore) 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

-- | A list of CA certificates to be added to the trust store.
createTrustStore_certificateList :: Lens.Lens' CreateTrustStore [Prelude.ByteString]
createTrustStore_certificateList :: Lens' CreateTrustStore [ByteString]
createTrustStore_certificateList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrustStore' {[Base64]
certificateList :: [Base64]
$sel:certificateList:CreateTrustStore' :: CreateTrustStore -> [Base64]
certificateList} -> [Base64]
certificateList) (\s :: CreateTrustStore
s@CreateTrustStore' {} [Base64]
a -> CreateTrustStore
s {$sel:certificateList:CreateTrustStore' :: [Base64]
certificateList = [Base64]
a} :: CreateTrustStore) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateTrustStore where
  type
    AWSResponse CreateTrustStore =
      CreateTrustStoreResponse
  request :: (Service -> Service)
-> CreateTrustStore -> Request CreateTrustStore
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 CreateTrustStore
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTrustStore)))
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 -> CreateTrustStoreResponse
CreateTrustStoreResponse'
            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
"trustStoreArn")
      )

instance Prelude.Hashable CreateTrustStore where
  hashWithSalt :: Int -> CreateTrustStore -> Int
hashWithSalt Int
_salt CreateTrustStore' {[Base64]
Maybe [Sensitive Tag]
Maybe Text
certificateList :: [Base64]
tags :: Maybe [Sensitive Tag]
clientToken :: Maybe Text
$sel:certificateList:CreateTrustStore' :: CreateTrustStore -> [Base64]
$sel:tags:CreateTrustStore' :: CreateTrustStore -> Maybe [Sensitive Tag]
$sel:clientToken:CreateTrustStore' :: CreateTrustStore -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Sensitive Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Base64]
certificateList

instance Prelude.NFData CreateTrustStore where
  rnf :: CreateTrustStore -> ()
rnf CreateTrustStore' {[Base64]
Maybe [Sensitive Tag]
Maybe Text
certificateList :: [Base64]
tags :: Maybe [Sensitive Tag]
clientToken :: Maybe Text
$sel:certificateList:CreateTrustStore' :: CreateTrustStore -> [Base64]
$sel:tags:CreateTrustStore' :: CreateTrustStore -> Maybe [Sensitive Tag]
$sel:clientToken:CreateTrustStore' :: CreateTrustStore -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Sensitive Tag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Base64]
certificateList

instance Data.ToHeaders CreateTrustStore where
  toHeaders :: CreateTrustStore -> 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 CreateTrustStore where
  toJSON :: CreateTrustStore -> Value
toJSON CreateTrustStore' {[Base64]
Maybe [Sensitive Tag]
Maybe Text
certificateList :: [Base64]
tags :: Maybe [Sensitive Tag]
clientToken :: Maybe Text
$sel:certificateList:CreateTrustStore' :: CreateTrustStore -> [Base64]
$sel:tags:CreateTrustStore' :: CreateTrustStore -> Maybe [Sensitive Tag]
$sel:clientToken:CreateTrustStore' :: CreateTrustStore -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"clientToken" 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
clientToken,
            (Key
"tags" 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 [Sensitive Tag]
tags,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"certificateList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Base64]
certificateList)
          ]
      )

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

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

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

-- |
-- Create a value of 'CreateTrustStoreResponse' 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', 'createTrustStoreResponse_httpStatus' - The response's http status code.
--
-- 'trustStoreArn', 'createTrustStoreResponse_trustStoreArn' - The ARN of the trust store.
newCreateTrustStoreResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'trustStoreArn'
  Prelude.Text ->
  CreateTrustStoreResponse
newCreateTrustStoreResponse :: Int -> Text -> CreateTrustStoreResponse
newCreateTrustStoreResponse
  Int
pHttpStatus_
  Text
pTrustStoreArn_ =
    CreateTrustStoreResponse'
      { $sel:httpStatus:CreateTrustStoreResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:trustStoreArn:CreateTrustStoreResponse' :: Text
trustStoreArn = Text
pTrustStoreArn_
      }

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

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

instance Prelude.NFData CreateTrustStoreResponse where
  rnf :: CreateTrustStoreResponse -> ()
rnf CreateTrustStoreResponse' {Int
Text
trustStoreArn :: Text
httpStatus :: Int
$sel:trustStoreArn:CreateTrustStoreResponse' :: CreateTrustStoreResponse -> Text
$sel:httpStatus:CreateTrustStoreResponse' :: CreateTrustStoreResponse -> 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
trustStoreArn