{-# 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.PrivateNetworks.ActivateDeviceIdentifier
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Activates the specified device identifier.
module Amazonka.PrivateNetworks.ActivateDeviceIdentifier
  ( -- * Creating a Request
    ActivateDeviceIdentifier (..),
    newActivateDeviceIdentifier,

    -- * Request Lenses
    activateDeviceIdentifier_clientToken,
    activateDeviceIdentifier_deviceIdentifierArn,

    -- * Destructuring the Response
    ActivateDeviceIdentifierResponse (..),
    newActivateDeviceIdentifierResponse,

    -- * Response Lenses
    activateDeviceIdentifierResponse_tags,
    activateDeviceIdentifierResponse_httpStatus,
    activateDeviceIdentifierResponse_deviceIdentifier,
  )
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 Amazonka.PrivateNetworks.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newActivateDeviceIdentifier' smart constructor.
data ActivateDeviceIdentifier = ActivateDeviceIdentifier'
  { -- | Unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request. For more information, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html How to ensure idempotency>.
    ActivateDeviceIdentifier -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the device identifier.
    ActivateDeviceIdentifier -> Text
deviceIdentifierArn :: Prelude.Text
  }
  deriving (ActivateDeviceIdentifier -> ActivateDeviceIdentifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActivateDeviceIdentifier -> ActivateDeviceIdentifier -> Bool
$c/= :: ActivateDeviceIdentifier -> ActivateDeviceIdentifier -> Bool
== :: ActivateDeviceIdentifier -> ActivateDeviceIdentifier -> Bool
$c== :: ActivateDeviceIdentifier -> ActivateDeviceIdentifier -> Bool
Prelude.Eq, ReadPrec [ActivateDeviceIdentifier]
ReadPrec ActivateDeviceIdentifier
Int -> ReadS ActivateDeviceIdentifier
ReadS [ActivateDeviceIdentifier]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActivateDeviceIdentifier]
$creadListPrec :: ReadPrec [ActivateDeviceIdentifier]
readPrec :: ReadPrec ActivateDeviceIdentifier
$creadPrec :: ReadPrec ActivateDeviceIdentifier
readList :: ReadS [ActivateDeviceIdentifier]
$creadList :: ReadS [ActivateDeviceIdentifier]
readsPrec :: Int -> ReadS ActivateDeviceIdentifier
$creadsPrec :: Int -> ReadS ActivateDeviceIdentifier
Prelude.Read, Int -> ActivateDeviceIdentifier -> ShowS
[ActivateDeviceIdentifier] -> ShowS
ActivateDeviceIdentifier -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActivateDeviceIdentifier] -> ShowS
$cshowList :: [ActivateDeviceIdentifier] -> ShowS
show :: ActivateDeviceIdentifier -> String
$cshow :: ActivateDeviceIdentifier -> String
showsPrec :: Int -> ActivateDeviceIdentifier -> ShowS
$cshowsPrec :: Int -> ActivateDeviceIdentifier -> ShowS
Prelude.Show, forall x.
Rep ActivateDeviceIdentifier x -> ActivateDeviceIdentifier
forall x.
ActivateDeviceIdentifier -> Rep ActivateDeviceIdentifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ActivateDeviceIdentifier x -> ActivateDeviceIdentifier
$cfrom :: forall x.
ActivateDeviceIdentifier -> Rep ActivateDeviceIdentifier x
Prelude.Generic)

-- |
-- Create a value of 'ActivateDeviceIdentifier' 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', 'activateDeviceIdentifier_clientToken' - Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html How to ensure idempotency>.
--
-- 'deviceIdentifierArn', 'activateDeviceIdentifier_deviceIdentifierArn' - The Amazon Resource Name (ARN) of the device identifier.
newActivateDeviceIdentifier ::
  -- | 'deviceIdentifierArn'
  Prelude.Text ->
  ActivateDeviceIdentifier
newActivateDeviceIdentifier :: Text -> ActivateDeviceIdentifier
newActivateDeviceIdentifier Text
pDeviceIdentifierArn_ =
  ActivateDeviceIdentifier'
    { $sel:clientToken:ActivateDeviceIdentifier' :: Maybe Text
clientToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:deviceIdentifierArn:ActivateDeviceIdentifier' :: Text
deviceIdentifierArn = Text
pDeviceIdentifierArn_
    }

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html How to ensure idempotency>.
activateDeviceIdentifier_clientToken :: Lens.Lens' ActivateDeviceIdentifier (Prelude.Maybe Prelude.Text)
activateDeviceIdentifier_clientToken :: Lens' ActivateDeviceIdentifier (Maybe Text)
activateDeviceIdentifier_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivateDeviceIdentifier' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:ActivateDeviceIdentifier' :: ActivateDeviceIdentifier -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: ActivateDeviceIdentifier
s@ActivateDeviceIdentifier' {} Maybe Text
a -> ActivateDeviceIdentifier
s {$sel:clientToken:ActivateDeviceIdentifier' :: Maybe Text
clientToken = Maybe Text
a} :: ActivateDeviceIdentifier)

-- | The Amazon Resource Name (ARN) of the device identifier.
activateDeviceIdentifier_deviceIdentifierArn :: Lens.Lens' ActivateDeviceIdentifier Prelude.Text
activateDeviceIdentifier_deviceIdentifierArn :: Lens' ActivateDeviceIdentifier Text
activateDeviceIdentifier_deviceIdentifierArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivateDeviceIdentifier' {Text
deviceIdentifierArn :: Text
$sel:deviceIdentifierArn:ActivateDeviceIdentifier' :: ActivateDeviceIdentifier -> Text
deviceIdentifierArn} -> Text
deviceIdentifierArn) (\s :: ActivateDeviceIdentifier
s@ActivateDeviceIdentifier' {} Text
a -> ActivateDeviceIdentifier
s {$sel:deviceIdentifierArn:ActivateDeviceIdentifier' :: Text
deviceIdentifierArn = Text
a} :: ActivateDeviceIdentifier)

instance Core.AWSRequest ActivateDeviceIdentifier where
  type
    AWSResponse ActivateDeviceIdentifier =
      ActivateDeviceIdentifierResponse
  request :: (Service -> Service)
-> ActivateDeviceIdentifier -> Request ActivateDeviceIdentifier
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 ActivateDeviceIdentifier
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ActivateDeviceIdentifier)))
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 ->
          Maybe (Sensitive (HashMap Text Text))
-> Int -> DeviceIdentifier -> ActivateDeviceIdentifierResponse
ActivateDeviceIdentifierResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"tags" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => 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
"deviceIdentifier")
      )

instance Prelude.Hashable ActivateDeviceIdentifier where
  hashWithSalt :: Int -> ActivateDeviceIdentifier -> Int
hashWithSalt Int
_salt ActivateDeviceIdentifier' {Maybe Text
Text
deviceIdentifierArn :: Text
clientToken :: Maybe Text
$sel:deviceIdentifierArn:ActivateDeviceIdentifier' :: ActivateDeviceIdentifier -> Text
$sel:clientToken:ActivateDeviceIdentifier' :: ActivateDeviceIdentifier -> 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` Text
deviceIdentifierArn

instance Prelude.NFData ActivateDeviceIdentifier where
  rnf :: ActivateDeviceIdentifier -> ()
rnf ActivateDeviceIdentifier' {Maybe Text
Text
deviceIdentifierArn :: Text
clientToken :: Maybe Text
$sel:deviceIdentifierArn:ActivateDeviceIdentifier' :: ActivateDeviceIdentifier -> Text
$sel:clientToken:ActivateDeviceIdentifier' :: ActivateDeviceIdentifier -> 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 Text
deviceIdentifierArn

instance Data.ToHeaders ActivateDeviceIdentifier where
  toHeaders :: ActivateDeviceIdentifier -> 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 ActivateDeviceIdentifier where
  toJSON :: ActivateDeviceIdentifier -> Value
toJSON ActivateDeviceIdentifier' {Maybe Text
Text
deviceIdentifierArn :: Text
clientToken :: Maybe Text
$sel:deviceIdentifierArn:ActivateDeviceIdentifier' :: ActivateDeviceIdentifier -> Text
$sel:clientToken:ActivateDeviceIdentifier' :: ActivateDeviceIdentifier -> 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,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"deviceIdentifierArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
deviceIdentifierArn)
          ]
      )

instance Data.ToPath ActivateDeviceIdentifier where
  toPath :: ActivateDeviceIdentifier -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const ByteString
"/v1/device-identifiers/activate"

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

-- | /See:/ 'newActivateDeviceIdentifierResponse' smart constructor.
data ActivateDeviceIdentifierResponse = ActivateDeviceIdentifierResponse'
  { -- | The tags on the device identifier.
    ActivateDeviceIdentifierResponse
-> Maybe (Sensitive (HashMap Text Text))
tags :: Prelude.Maybe (Data.Sensitive (Prelude.HashMap Prelude.Text Prelude.Text)),
    -- | The response's http status code.
    ActivateDeviceIdentifierResponse -> Int
httpStatus :: Prelude.Int,
    -- | Information about the device identifier.
    ActivateDeviceIdentifierResponse -> DeviceIdentifier
deviceIdentifier :: DeviceIdentifier
  }
  deriving (ActivateDeviceIdentifierResponse
-> ActivateDeviceIdentifierResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActivateDeviceIdentifierResponse
-> ActivateDeviceIdentifierResponse -> Bool
$c/= :: ActivateDeviceIdentifierResponse
-> ActivateDeviceIdentifierResponse -> Bool
== :: ActivateDeviceIdentifierResponse
-> ActivateDeviceIdentifierResponse -> Bool
$c== :: ActivateDeviceIdentifierResponse
-> ActivateDeviceIdentifierResponse -> Bool
Prelude.Eq, Int -> ActivateDeviceIdentifierResponse -> ShowS
[ActivateDeviceIdentifierResponse] -> ShowS
ActivateDeviceIdentifierResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActivateDeviceIdentifierResponse] -> ShowS
$cshowList :: [ActivateDeviceIdentifierResponse] -> ShowS
show :: ActivateDeviceIdentifierResponse -> String
$cshow :: ActivateDeviceIdentifierResponse -> String
showsPrec :: Int -> ActivateDeviceIdentifierResponse -> ShowS
$cshowsPrec :: Int -> ActivateDeviceIdentifierResponse -> ShowS
Prelude.Show, forall x.
Rep ActivateDeviceIdentifierResponse x
-> ActivateDeviceIdentifierResponse
forall x.
ActivateDeviceIdentifierResponse
-> Rep ActivateDeviceIdentifierResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ActivateDeviceIdentifierResponse x
-> ActivateDeviceIdentifierResponse
$cfrom :: forall x.
ActivateDeviceIdentifierResponse
-> Rep ActivateDeviceIdentifierResponse x
Prelude.Generic)

-- |
-- Create a value of 'ActivateDeviceIdentifierResponse' 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:
--
-- 'tags', 'activateDeviceIdentifierResponse_tags' - The tags on the device identifier.
--
-- 'httpStatus', 'activateDeviceIdentifierResponse_httpStatus' - The response's http status code.
--
-- 'deviceIdentifier', 'activateDeviceIdentifierResponse_deviceIdentifier' - Information about the device identifier.
newActivateDeviceIdentifierResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'deviceIdentifier'
  DeviceIdentifier ->
  ActivateDeviceIdentifierResponse
newActivateDeviceIdentifierResponse :: Int -> DeviceIdentifier -> ActivateDeviceIdentifierResponse
newActivateDeviceIdentifierResponse
  Int
pHttpStatus_
  DeviceIdentifier
pDeviceIdentifier_ =
    ActivateDeviceIdentifierResponse'
      { $sel:tags:ActivateDeviceIdentifierResponse' :: Maybe (Sensitive (HashMap Text Text))
tags =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:ActivateDeviceIdentifierResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:deviceIdentifier:ActivateDeviceIdentifierResponse' :: DeviceIdentifier
deviceIdentifier = DeviceIdentifier
pDeviceIdentifier_
      }

-- | The tags on the device identifier.
activateDeviceIdentifierResponse_tags :: Lens.Lens' ActivateDeviceIdentifierResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
activateDeviceIdentifierResponse_tags :: Lens' ActivateDeviceIdentifierResponse (Maybe (HashMap Text Text))
activateDeviceIdentifierResponse_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivateDeviceIdentifierResponse' {Maybe (Sensitive (HashMap Text Text))
tags :: Maybe (Sensitive (HashMap Text Text))
$sel:tags:ActivateDeviceIdentifierResponse' :: ActivateDeviceIdentifierResponse
-> Maybe (Sensitive (HashMap Text Text))
tags} -> Maybe (Sensitive (HashMap Text Text))
tags) (\s :: ActivateDeviceIdentifierResponse
s@ActivateDeviceIdentifierResponse' {} Maybe (Sensitive (HashMap Text Text))
a -> ActivateDeviceIdentifierResponse
s {$sel:tags:ActivateDeviceIdentifierResponse' :: Maybe (Sensitive (HashMap Text Text))
tags = Maybe (Sensitive (HashMap Text Text))
a} :: ActivateDeviceIdentifierResponse) 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 a. Iso' (Sensitive a) a
Data._Sensitive 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)

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

-- | Information about the device identifier.
activateDeviceIdentifierResponse_deviceIdentifier :: Lens.Lens' ActivateDeviceIdentifierResponse DeviceIdentifier
activateDeviceIdentifierResponse_deviceIdentifier :: Lens' ActivateDeviceIdentifierResponse DeviceIdentifier
activateDeviceIdentifierResponse_deviceIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivateDeviceIdentifierResponse' {DeviceIdentifier
deviceIdentifier :: DeviceIdentifier
$sel:deviceIdentifier:ActivateDeviceIdentifierResponse' :: ActivateDeviceIdentifierResponse -> DeviceIdentifier
deviceIdentifier} -> DeviceIdentifier
deviceIdentifier) (\s :: ActivateDeviceIdentifierResponse
s@ActivateDeviceIdentifierResponse' {} DeviceIdentifier
a -> ActivateDeviceIdentifierResponse
s {$sel:deviceIdentifier:ActivateDeviceIdentifierResponse' :: DeviceIdentifier
deviceIdentifier = DeviceIdentifier
a} :: ActivateDeviceIdentifierResponse)

instance
  Prelude.NFData
    ActivateDeviceIdentifierResponse
  where
  rnf :: ActivateDeviceIdentifierResponse -> ()
rnf ActivateDeviceIdentifierResponse' {Int
Maybe (Sensitive (HashMap Text Text))
DeviceIdentifier
deviceIdentifier :: DeviceIdentifier
httpStatus :: Int
tags :: Maybe (Sensitive (HashMap Text Text))
$sel:deviceIdentifier:ActivateDeviceIdentifierResponse' :: ActivateDeviceIdentifierResponse -> DeviceIdentifier
$sel:httpStatus:ActivateDeviceIdentifierResponse' :: ActivateDeviceIdentifierResponse -> Int
$sel:tags:ActivateDeviceIdentifierResponse' :: ActivateDeviceIdentifierResponse
-> Maybe (Sensitive (HashMap Text Text))
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive (HashMap Text Text))
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 DeviceIdentifier
deviceIdentifier