{-# 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.AssociateSecurityKey
-- 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 a security key to the instance.
module Amazonka.Connect.AssociateSecurityKey
  ( -- * Creating a Request
    AssociateSecurityKey (..),
    newAssociateSecurityKey,

    -- * Request Lenses
    associateSecurityKey_instanceId,
    associateSecurityKey_key,

    -- * Destructuring the Response
    AssociateSecurityKeyResponse (..),
    newAssociateSecurityKeyResponse,

    -- * Response Lenses
    associateSecurityKeyResponse_associationId,
    associateSecurityKeyResponse_httpStatus,
  )
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:/ 'newAssociateSecurityKey' smart constructor.
data AssociateSecurityKey = AssociateSecurityKey'
  { -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    AssociateSecurityKey -> Text
instanceId :: Prelude.Text,
    -- | A valid security key in PEM format.
    AssociateSecurityKey -> Text
key :: Prelude.Text
  }
  deriving (AssociateSecurityKey -> AssociateSecurityKey -> Bool
(AssociateSecurityKey -> AssociateSecurityKey -> Bool)
-> (AssociateSecurityKey -> AssociateSecurityKey -> Bool)
-> Eq AssociateSecurityKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateSecurityKey -> AssociateSecurityKey -> Bool
$c/= :: AssociateSecurityKey -> AssociateSecurityKey -> Bool
== :: AssociateSecurityKey -> AssociateSecurityKey -> Bool
$c== :: AssociateSecurityKey -> AssociateSecurityKey -> Bool
Prelude.Eq, ReadPrec [AssociateSecurityKey]
ReadPrec AssociateSecurityKey
Int -> ReadS AssociateSecurityKey
ReadS [AssociateSecurityKey]
(Int -> ReadS AssociateSecurityKey)
-> ReadS [AssociateSecurityKey]
-> ReadPrec AssociateSecurityKey
-> ReadPrec [AssociateSecurityKey]
-> Read AssociateSecurityKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateSecurityKey]
$creadListPrec :: ReadPrec [AssociateSecurityKey]
readPrec :: ReadPrec AssociateSecurityKey
$creadPrec :: ReadPrec AssociateSecurityKey
readList :: ReadS [AssociateSecurityKey]
$creadList :: ReadS [AssociateSecurityKey]
readsPrec :: Int -> ReadS AssociateSecurityKey
$creadsPrec :: Int -> ReadS AssociateSecurityKey
Prelude.Read, Int -> AssociateSecurityKey -> ShowS
[AssociateSecurityKey] -> ShowS
AssociateSecurityKey -> String
(Int -> AssociateSecurityKey -> ShowS)
-> (AssociateSecurityKey -> String)
-> ([AssociateSecurityKey] -> ShowS)
-> Show AssociateSecurityKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateSecurityKey] -> ShowS
$cshowList :: [AssociateSecurityKey] -> ShowS
show :: AssociateSecurityKey -> String
$cshow :: AssociateSecurityKey -> String
showsPrec :: Int -> AssociateSecurityKey -> ShowS
$cshowsPrec :: Int -> AssociateSecurityKey -> ShowS
Prelude.Show, (forall x. AssociateSecurityKey -> Rep AssociateSecurityKey x)
-> (forall x. Rep AssociateSecurityKey x -> AssociateSecurityKey)
-> Generic AssociateSecurityKey
forall x. Rep AssociateSecurityKey x -> AssociateSecurityKey
forall x. AssociateSecurityKey -> Rep AssociateSecurityKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateSecurityKey x -> AssociateSecurityKey
$cfrom :: forall x. AssociateSecurityKey -> Rep AssociateSecurityKey x
Prelude.Generic)

-- |
-- Create a value of 'AssociateSecurityKey' 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', 'associateSecurityKey_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
--
-- 'key', 'associateSecurityKey_key' - A valid security key in PEM format.
newAssociateSecurityKey ::
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'key'
  Prelude.Text ->
  AssociateSecurityKey
newAssociateSecurityKey :: Text -> Text -> AssociateSecurityKey
newAssociateSecurityKey Text
pInstanceId_ Text
pKey_ =
  AssociateSecurityKey' :: Text -> Text -> AssociateSecurityKey
AssociateSecurityKey'
    { $sel:instanceId:AssociateSecurityKey' :: Text
instanceId = Text
pInstanceId_,
      $sel:key:AssociateSecurityKey' :: Text
key = Text
pKey_
    }

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

-- | A valid security key in PEM format.
associateSecurityKey_key :: Lens.Lens' AssociateSecurityKey Prelude.Text
associateSecurityKey_key :: (Text -> f Text) -> AssociateSecurityKey -> f AssociateSecurityKey
associateSecurityKey_key = (AssociateSecurityKey -> Text)
-> (AssociateSecurityKey -> Text -> AssociateSecurityKey)
-> Lens AssociateSecurityKey AssociateSecurityKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateSecurityKey' {Text
key :: Text
$sel:key:AssociateSecurityKey' :: AssociateSecurityKey -> Text
key} -> Text
key) (\s :: AssociateSecurityKey
s@AssociateSecurityKey' {} Text
a -> AssociateSecurityKey
s {$sel:key:AssociateSecurityKey' :: Text
key = Text
a} :: AssociateSecurityKey)

instance Core.AWSRequest AssociateSecurityKey where
  type
    AWSResponse AssociateSecurityKey =
      AssociateSecurityKeyResponse
  request :: AssociateSecurityKey -> Request AssociateSecurityKey
request = Service -> AssociateSecurityKey -> Request AssociateSecurityKey
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateSecurityKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateSecurityKey)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse AssociateSecurityKey))
-> Logger
-> Service
-> Proxy AssociateSecurityKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateSecurityKey)))
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 Text -> Int -> AssociateSecurityKeyResponse
AssociateSecurityKeyResponse'
            (Maybe Text -> Int -> AssociateSecurityKeyResponse)
-> Either String (Maybe Text)
-> Either String (Int -> AssociateSecurityKeyResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AssociationId")
            Either String (Int -> AssociateSecurityKeyResponse)
-> Either String Int -> Either String AssociateSecurityKeyResponse
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 AssociateSecurityKey

instance Prelude.NFData AssociateSecurityKey

instance Core.ToHeaders AssociateSecurityKey where
  toHeaders :: AssociateSecurityKey -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AssociateSecurityKey -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 AssociateSecurityKey where
  toJSON :: AssociateSecurityKey -> Value
toJSON AssociateSecurityKey' {Text
key :: Text
instanceId :: Text
$sel:key:AssociateSecurityKey' :: AssociateSecurityKey -> Text
$sel:instanceId:AssociateSecurityKey' :: AssociateSecurityKey -> 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
"Key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key)]
      )

instance Core.ToPath AssociateSecurityKey where
  toPath :: AssociateSecurityKey -> ByteString
toPath AssociateSecurityKey' {Text
key :: Text
instanceId :: Text
$sel:key:AssociateSecurityKey' :: AssociateSecurityKey -> Text
$sel:instanceId:AssociateSecurityKey' :: AssociateSecurityKey -> 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
"/security-key"]

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

-- | /See:/ 'newAssociateSecurityKeyResponse' smart constructor.
data AssociateSecurityKeyResponse = AssociateSecurityKeyResponse'
  { -- | The existing association identifier that uniquely identifies the
    -- resource type and storage config for the given instance ID.
    AssociateSecurityKeyResponse -> Maybe Text
associationId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    AssociateSecurityKeyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AssociateSecurityKeyResponse
-> AssociateSecurityKeyResponse -> Bool
(AssociateSecurityKeyResponse
 -> AssociateSecurityKeyResponse -> Bool)
-> (AssociateSecurityKeyResponse
    -> AssociateSecurityKeyResponse -> Bool)
-> Eq AssociateSecurityKeyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateSecurityKeyResponse
-> AssociateSecurityKeyResponse -> Bool
$c/= :: AssociateSecurityKeyResponse
-> AssociateSecurityKeyResponse -> Bool
== :: AssociateSecurityKeyResponse
-> AssociateSecurityKeyResponse -> Bool
$c== :: AssociateSecurityKeyResponse
-> AssociateSecurityKeyResponse -> Bool
Prelude.Eq, ReadPrec [AssociateSecurityKeyResponse]
ReadPrec AssociateSecurityKeyResponse
Int -> ReadS AssociateSecurityKeyResponse
ReadS [AssociateSecurityKeyResponse]
(Int -> ReadS AssociateSecurityKeyResponse)
-> ReadS [AssociateSecurityKeyResponse]
-> ReadPrec AssociateSecurityKeyResponse
-> ReadPrec [AssociateSecurityKeyResponse]
-> Read AssociateSecurityKeyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateSecurityKeyResponse]
$creadListPrec :: ReadPrec [AssociateSecurityKeyResponse]
readPrec :: ReadPrec AssociateSecurityKeyResponse
$creadPrec :: ReadPrec AssociateSecurityKeyResponse
readList :: ReadS [AssociateSecurityKeyResponse]
$creadList :: ReadS [AssociateSecurityKeyResponse]
readsPrec :: Int -> ReadS AssociateSecurityKeyResponse
$creadsPrec :: Int -> ReadS AssociateSecurityKeyResponse
Prelude.Read, Int -> AssociateSecurityKeyResponse -> ShowS
[AssociateSecurityKeyResponse] -> ShowS
AssociateSecurityKeyResponse -> String
(Int -> AssociateSecurityKeyResponse -> ShowS)
-> (AssociateSecurityKeyResponse -> String)
-> ([AssociateSecurityKeyResponse] -> ShowS)
-> Show AssociateSecurityKeyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateSecurityKeyResponse] -> ShowS
$cshowList :: [AssociateSecurityKeyResponse] -> ShowS
show :: AssociateSecurityKeyResponse -> String
$cshow :: AssociateSecurityKeyResponse -> String
showsPrec :: Int -> AssociateSecurityKeyResponse -> ShowS
$cshowsPrec :: Int -> AssociateSecurityKeyResponse -> ShowS
Prelude.Show, (forall x.
 AssociateSecurityKeyResponse -> Rep AssociateSecurityKeyResponse x)
-> (forall x.
    Rep AssociateSecurityKeyResponse x -> AssociateSecurityKeyResponse)
-> Generic AssociateSecurityKeyResponse
forall x.
Rep AssociateSecurityKeyResponse x -> AssociateSecurityKeyResponse
forall x.
AssociateSecurityKeyResponse -> Rep AssociateSecurityKeyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateSecurityKeyResponse x -> AssociateSecurityKeyResponse
$cfrom :: forall x.
AssociateSecurityKeyResponse -> Rep AssociateSecurityKeyResponse x
Prelude.Generic)

-- |
-- Create a value of 'AssociateSecurityKeyResponse' 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:
--
-- 'associationId', 'associateSecurityKeyResponse_associationId' - The existing association identifier that uniquely identifies the
-- resource type and storage config for the given instance ID.
--
-- 'httpStatus', 'associateSecurityKeyResponse_httpStatus' - The response's http status code.
newAssociateSecurityKeyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AssociateSecurityKeyResponse
newAssociateSecurityKeyResponse :: Int -> AssociateSecurityKeyResponse
newAssociateSecurityKeyResponse Int
pHttpStatus_ =
  AssociateSecurityKeyResponse' :: Maybe Text -> Int -> AssociateSecurityKeyResponse
AssociateSecurityKeyResponse'
    { $sel:associationId:AssociateSecurityKeyResponse' :: Maybe Text
associationId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AssociateSecurityKeyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The existing association identifier that uniquely identifies the
-- resource type and storage config for the given instance ID.
associateSecurityKeyResponse_associationId :: Lens.Lens' AssociateSecurityKeyResponse (Prelude.Maybe Prelude.Text)
associateSecurityKeyResponse_associationId :: (Maybe Text -> f (Maybe Text))
-> AssociateSecurityKeyResponse -> f AssociateSecurityKeyResponse
associateSecurityKeyResponse_associationId = (AssociateSecurityKeyResponse -> Maybe Text)
-> (AssociateSecurityKeyResponse
    -> Maybe Text -> AssociateSecurityKeyResponse)
-> Lens
     AssociateSecurityKeyResponse
     AssociateSecurityKeyResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateSecurityKeyResponse' {Maybe Text
associationId :: Maybe Text
$sel:associationId:AssociateSecurityKeyResponse' :: AssociateSecurityKeyResponse -> Maybe Text
associationId} -> Maybe Text
associationId) (\s :: AssociateSecurityKeyResponse
s@AssociateSecurityKeyResponse' {} Maybe Text
a -> AssociateSecurityKeyResponse
s {$sel:associationId:AssociateSecurityKeyResponse' :: Maybe Text
associationId = Maybe Text
a} :: AssociateSecurityKeyResponse)

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

instance Prelude.NFData AssociateSecurityKeyResponse