{-# 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.Connect.AssociateApprovedOrigin
-- 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)
--
-- This API is in preview release for Amazon Connect and is subject to
-- change.
--
-- Associates an approved origin to an Amazon Connect instance.
module Amazonka.Connect.AssociateApprovedOrigin
  ( -- * Creating a Request
    AssociateApprovedOrigin (..),
    newAssociateApprovedOrigin,

    -- * Request Lenses
    associateApprovedOrigin_instanceId,
    associateApprovedOrigin_origin,

    -- * Destructuring the Response
    AssociateApprovedOriginResponse (..),
    newAssociateApprovedOriginResponse,
  )
where

import Amazonka.Connect.Types
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

-- | /See:/ 'newAssociateApprovedOrigin' smart constructor.
data AssociateApprovedOrigin = AssociateApprovedOrigin'
  { -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    AssociateApprovedOrigin -> Text
instanceId :: Prelude.Text,
    -- | The domain to add to your allow list.
    AssociateApprovedOrigin -> Text
origin :: Prelude.Text
  }
  deriving (AssociateApprovedOrigin -> AssociateApprovedOrigin -> Bool
(AssociateApprovedOrigin -> AssociateApprovedOrigin -> Bool)
-> (AssociateApprovedOrigin -> AssociateApprovedOrigin -> Bool)
-> Eq AssociateApprovedOrigin
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateApprovedOrigin -> AssociateApprovedOrigin -> Bool
$c/= :: AssociateApprovedOrigin -> AssociateApprovedOrigin -> Bool
== :: AssociateApprovedOrigin -> AssociateApprovedOrigin -> Bool
$c== :: AssociateApprovedOrigin -> AssociateApprovedOrigin -> Bool
Prelude.Eq, ReadPrec [AssociateApprovedOrigin]
ReadPrec AssociateApprovedOrigin
Int -> ReadS AssociateApprovedOrigin
ReadS [AssociateApprovedOrigin]
(Int -> ReadS AssociateApprovedOrigin)
-> ReadS [AssociateApprovedOrigin]
-> ReadPrec AssociateApprovedOrigin
-> ReadPrec [AssociateApprovedOrigin]
-> Read AssociateApprovedOrigin
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateApprovedOrigin]
$creadListPrec :: ReadPrec [AssociateApprovedOrigin]
readPrec :: ReadPrec AssociateApprovedOrigin
$creadPrec :: ReadPrec AssociateApprovedOrigin
readList :: ReadS [AssociateApprovedOrigin]
$creadList :: ReadS [AssociateApprovedOrigin]
readsPrec :: Int -> ReadS AssociateApprovedOrigin
$creadsPrec :: Int -> ReadS AssociateApprovedOrigin
Prelude.Read, Int -> AssociateApprovedOrigin -> ShowS
[AssociateApprovedOrigin] -> ShowS
AssociateApprovedOrigin -> String
(Int -> AssociateApprovedOrigin -> ShowS)
-> (AssociateApprovedOrigin -> String)
-> ([AssociateApprovedOrigin] -> ShowS)
-> Show AssociateApprovedOrigin
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateApprovedOrigin] -> ShowS
$cshowList :: [AssociateApprovedOrigin] -> ShowS
show :: AssociateApprovedOrigin -> String
$cshow :: AssociateApprovedOrigin -> String
showsPrec :: Int -> AssociateApprovedOrigin -> ShowS
$cshowsPrec :: Int -> AssociateApprovedOrigin -> ShowS
Prelude.Show, (forall x.
 AssociateApprovedOrigin -> Rep AssociateApprovedOrigin x)
-> (forall x.
    Rep AssociateApprovedOrigin x -> AssociateApprovedOrigin)
-> Generic AssociateApprovedOrigin
forall x. Rep AssociateApprovedOrigin x -> AssociateApprovedOrigin
forall x. AssociateApprovedOrigin -> Rep AssociateApprovedOrigin x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateApprovedOrigin x -> AssociateApprovedOrigin
$cfrom :: forall x. AssociateApprovedOrigin -> Rep AssociateApprovedOrigin x
Prelude.Generic)

-- |
-- Create a value of 'AssociateApprovedOrigin' 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:
--
-- 'instanceId', 'associateApprovedOrigin_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
--
-- 'origin', 'associateApprovedOrigin_origin' - The domain to add to your allow list.
newAssociateApprovedOrigin ::
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'origin'
  Prelude.Text ->
  AssociateApprovedOrigin
newAssociateApprovedOrigin :: Text -> Text -> AssociateApprovedOrigin
newAssociateApprovedOrigin Text
pInstanceId_ Text
pOrigin_ =
  AssociateApprovedOrigin' :: Text -> Text -> AssociateApprovedOrigin
AssociateApprovedOrigin'
    { $sel:instanceId:AssociateApprovedOrigin' :: Text
instanceId = Text
pInstanceId_,
      $sel:origin:AssociateApprovedOrigin' :: Text
origin = Text
pOrigin_
    }

-- | The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
associateApprovedOrigin_instanceId :: Lens.Lens' AssociateApprovedOrigin Prelude.Text
associateApprovedOrigin_instanceId :: (Text -> f Text)
-> AssociateApprovedOrigin -> f AssociateApprovedOrigin
associateApprovedOrigin_instanceId = (AssociateApprovedOrigin -> Text)
-> (AssociateApprovedOrigin -> Text -> AssociateApprovedOrigin)
-> Lens AssociateApprovedOrigin AssociateApprovedOrigin Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateApprovedOrigin' {Text
instanceId :: Text
$sel:instanceId:AssociateApprovedOrigin' :: AssociateApprovedOrigin -> Text
instanceId} -> Text
instanceId) (\s :: AssociateApprovedOrigin
s@AssociateApprovedOrigin' {} Text
a -> AssociateApprovedOrigin
s {$sel:instanceId:AssociateApprovedOrigin' :: Text
instanceId = Text
a} :: AssociateApprovedOrigin)

-- | The domain to add to your allow list.
associateApprovedOrigin_origin :: Lens.Lens' AssociateApprovedOrigin Prelude.Text
associateApprovedOrigin_origin :: (Text -> f Text)
-> AssociateApprovedOrigin -> f AssociateApprovedOrigin
associateApprovedOrigin_origin = (AssociateApprovedOrigin -> Text)
-> (AssociateApprovedOrigin -> Text -> AssociateApprovedOrigin)
-> Lens AssociateApprovedOrigin AssociateApprovedOrigin Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateApprovedOrigin' {Text
origin :: Text
$sel:origin:AssociateApprovedOrigin' :: AssociateApprovedOrigin -> Text
origin} -> Text
origin) (\s :: AssociateApprovedOrigin
s@AssociateApprovedOrigin' {} Text
a -> AssociateApprovedOrigin
s {$sel:origin:AssociateApprovedOrigin' :: Text
origin = Text
a} :: AssociateApprovedOrigin)

instance Core.AWSRequest AssociateApprovedOrigin where
  type
    AWSResponse AssociateApprovedOrigin =
      AssociateApprovedOriginResponse
  request :: AssociateApprovedOrigin -> Request AssociateApprovedOrigin
request = Service
-> AssociateApprovedOrigin -> Request AssociateApprovedOrigin
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateApprovedOrigin
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateApprovedOrigin)))
response =
    AWSResponse AssociateApprovedOrigin
-> Logger
-> Service
-> Proxy AssociateApprovedOrigin
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateApprovedOrigin)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse AssociateApprovedOrigin
AssociateApprovedOriginResponse
AssociateApprovedOriginResponse'

instance Prelude.Hashable AssociateApprovedOrigin

instance Prelude.NFData AssociateApprovedOrigin

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

instance Core.ToJSON AssociateApprovedOrigin where
  toJSON :: AssociateApprovedOrigin -> Value
toJSON AssociateApprovedOrigin' {Text
origin :: Text
instanceId :: Text
$sel:origin:AssociateApprovedOrigin' :: AssociateApprovedOrigin -> Text
$sel:instanceId:AssociateApprovedOrigin' :: AssociateApprovedOrigin -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Origin" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
origin)]
      )

instance Core.ToPath AssociateApprovedOrigin where
  toPath :: AssociateApprovedOrigin -> ByteString
toPath AssociateApprovedOrigin' {Text
origin :: Text
instanceId :: Text
$sel:origin:AssociateApprovedOrigin' :: AssociateApprovedOrigin -> Text
$sel:instanceId:AssociateApprovedOrigin' :: AssociateApprovedOrigin -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/instance/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
instanceId,
        ByteString
"/approved-origin"
      ]

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

-- | /See:/ 'newAssociateApprovedOriginResponse' smart constructor.
data AssociateApprovedOriginResponse = AssociateApprovedOriginResponse'
  {
  }
  deriving (AssociateApprovedOriginResponse
-> AssociateApprovedOriginResponse -> Bool
(AssociateApprovedOriginResponse
 -> AssociateApprovedOriginResponse -> Bool)
-> (AssociateApprovedOriginResponse
    -> AssociateApprovedOriginResponse -> Bool)
-> Eq AssociateApprovedOriginResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateApprovedOriginResponse
-> AssociateApprovedOriginResponse -> Bool
$c/= :: AssociateApprovedOriginResponse
-> AssociateApprovedOriginResponse -> Bool
== :: AssociateApprovedOriginResponse
-> AssociateApprovedOriginResponse -> Bool
$c== :: AssociateApprovedOriginResponse
-> AssociateApprovedOriginResponse -> Bool
Prelude.Eq, ReadPrec [AssociateApprovedOriginResponse]
ReadPrec AssociateApprovedOriginResponse
Int -> ReadS AssociateApprovedOriginResponse
ReadS [AssociateApprovedOriginResponse]
(Int -> ReadS AssociateApprovedOriginResponse)
-> ReadS [AssociateApprovedOriginResponse]
-> ReadPrec AssociateApprovedOriginResponse
-> ReadPrec [AssociateApprovedOriginResponse]
-> Read AssociateApprovedOriginResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateApprovedOriginResponse]
$creadListPrec :: ReadPrec [AssociateApprovedOriginResponse]
readPrec :: ReadPrec AssociateApprovedOriginResponse
$creadPrec :: ReadPrec AssociateApprovedOriginResponse
readList :: ReadS [AssociateApprovedOriginResponse]
$creadList :: ReadS [AssociateApprovedOriginResponse]
readsPrec :: Int -> ReadS AssociateApprovedOriginResponse
$creadsPrec :: Int -> ReadS AssociateApprovedOriginResponse
Prelude.Read, Int -> AssociateApprovedOriginResponse -> ShowS
[AssociateApprovedOriginResponse] -> ShowS
AssociateApprovedOriginResponse -> String
(Int -> AssociateApprovedOriginResponse -> ShowS)
-> (AssociateApprovedOriginResponse -> String)
-> ([AssociateApprovedOriginResponse] -> ShowS)
-> Show AssociateApprovedOriginResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateApprovedOriginResponse] -> ShowS
$cshowList :: [AssociateApprovedOriginResponse] -> ShowS
show :: AssociateApprovedOriginResponse -> String
$cshow :: AssociateApprovedOriginResponse -> String
showsPrec :: Int -> AssociateApprovedOriginResponse -> ShowS
$cshowsPrec :: Int -> AssociateApprovedOriginResponse -> ShowS
Prelude.Show, (forall x.
 AssociateApprovedOriginResponse
 -> Rep AssociateApprovedOriginResponse x)
-> (forall x.
    Rep AssociateApprovedOriginResponse x
    -> AssociateApprovedOriginResponse)
-> Generic AssociateApprovedOriginResponse
forall x.
Rep AssociateApprovedOriginResponse x
-> AssociateApprovedOriginResponse
forall x.
AssociateApprovedOriginResponse
-> Rep AssociateApprovedOriginResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateApprovedOriginResponse x
-> AssociateApprovedOriginResponse
$cfrom :: forall x.
AssociateApprovedOriginResponse
-> Rep AssociateApprovedOriginResponse x
Prelude.Generic)

-- |
-- Create a value of 'AssociateApprovedOriginResponse' 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.
newAssociateApprovedOriginResponse ::
  AssociateApprovedOriginResponse
newAssociateApprovedOriginResponse :: AssociateApprovedOriginResponse
newAssociateApprovedOriginResponse =
  AssociateApprovedOriginResponse
AssociateApprovedOriginResponse'

instance
  Prelude.NFData
    AssociateApprovedOriginResponse