{-# 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.Lightsail.DeleteKnownHostKeys
-- 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)
--
-- Deletes the known host key or certificate used by the Amazon Lightsail
-- browser-based SSH or RDP clients to authenticate an instance. This
-- operation enables the Lightsail browser-based SSH or RDP clients to
-- connect to the instance after a host key mismatch.
--
-- Perform this operation only if you were expecting the host key or
-- certificate mismatch or if you are familiar with the new host key or
-- certificate on the instance. For more information, see
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-troubleshooting-browser-based-ssh-rdp-client-connection Troubleshooting connection issues when using the Amazon Lightsail browser-based SSH or RDP client>.
module Amazonka.Lightsail.DeleteKnownHostKeys
  ( -- * Creating a Request
    DeleteKnownHostKeys (..),
    newDeleteKnownHostKeys,

    -- * Request Lenses
    deleteKnownHostKeys_instanceName,

    -- * Destructuring the Response
    DeleteKnownHostKeysResponse (..),
    newDeleteKnownHostKeysResponse,

    -- * Response Lenses
    deleteKnownHostKeysResponse_operations,
    deleteKnownHostKeysResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteKnownHostKeys' smart constructor.
data DeleteKnownHostKeys = DeleteKnownHostKeys'
  { -- | The name of the instance for which you want to reset the host key or
    -- certificate.
    DeleteKnownHostKeys -> Text
instanceName :: Prelude.Text
  }
  deriving (DeleteKnownHostKeys -> DeleteKnownHostKeys -> Bool
(DeleteKnownHostKeys -> DeleteKnownHostKeys -> Bool)
-> (DeleteKnownHostKeys -> DeleteKnownHostKeys -> Bool)
-> Eq DeleteKnownHostKeys
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteKnownHostKeys -> DeleteKnownHostKeys -> Bool
$c/= :: DeleteKnownHostKeys -> DeleteKnownHostKeys -> Bool
== :: DeleteKnownHostKeys -> DeleteKnownHostKeys -> Bool
$c== :: DeleteKnownHostKeys -> DeleteKnownHostKeys -> Bool
Prelude.Eq, ReadPrec [DeleteKnownHostKeys]
ReadPrec DeleteKnownHostKeys
Int -> ReadS DeleteKnownHostKeys
ReadS [DeleteKnownHostKeys]
(Int -> ReadS DeleteKnownHostKeys)
-> ReadS [DeleteKnownHostKeys]
-> ReadPrec DeleteKnownHostKeys
-> ReadPrec [DeleteKnownHostKeys]
-> Read DeleteKnownHostKeys
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteKnownHostKeys]
$creadListPrec :: ReadPrec [DeleteKnownHostKeys]
readPrec :: ReadPrec DeleteKnownHostKeys
$creadPrec :: ReadPrec DeleteKnownHostKeys
readList :: ReadS [DeleteKnownHostKeys]
$creadList :: ReadS [DeleteKnownHostKeys]
readsPrec :: Int -> ReadS DeleteKnownHostKeys
$creadsPrec :: Int -> ReadS DeleteKnownHostKeys
Prelude.Read, Int -> DeleteKnownHostKeys -> ShowS
[DeleteKnownHostKeys] -> ShowS
DeleteKnownHostKeys -> String
(Int -> DeleteKnownHostKeys -> ShowS)
-> (DeleteKnownHostKeys -> String)
-> ([DeleteKnownHostKeys] -> ShowS)
-> Show DeleteKnownHostKeys
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteKnownHostKeys] -> ShowS
$cshowList :: [DeleteKnownHostKeys] -> ShowS
show :: DeleteKnownHostKeys -> String
$cshow :: DeleteKnownHostKeys -> String
showsPrec :: Int -> DeleteKnownHostKeys -> ShowS
$cshowsPrec :: Int -> DeleteKnownHostKeys -> ShowS
Prelude.Show, (forall x. DeleteKnownHostKeys -> Rep DeleteKnownHostKeys x)
-> (forall x. Rep DeleteKnownHostKeys x -> DeleteKnownHostKeys)
-> Generic DeleteKnownHostKeys
forall x. Rep DeleteKnownHostKeys x -> DeleteKnownHostKeys
forall x. DeleteKnownHostKeys -> Rep DeleteKnownHostKeys x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteKnownHostKeys x -> DeleteKnownHostKeys
$cfrom :: forall x. DeleteKnownHostKeys -> Rep DeleteKnownHostKeys x
Prelude.Generic)

-- |
-- Create a value of 'DeleteKnownHostKeys' 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:
--
-- 'instanceName', 'deleteKnownHostKeys_instanceName' - The name of the instance for which you want to reset the host key or
-- certificate.
newDeleteKnownHostKeys ::
  -- | 'instanceName'
  Prelude.Text ->
  DeleteKnownHostKeys
newDeleteKnownHostKeys :: Text -> DeleteKnownHostKeys
newDeleteKnownHostKeys Text
pInstanceName_ =
  DeleteKnownHostKeys' :: Text -> DeleteKnownHostKeys
DeleteKnownHostKeys' {$sel:instanceName:DeleteKnownHostKeys' :: Text
instanceName = Text
pInstanceName_}

-- | The name of the instance for which you want to reset the host key or
-- certificate.
deleteKnownHostKeys_instanceName :: Lens.Lens' DeleteKnownHostKeys Prelude.Text
deleteKnownHostKeys_instanceName :: (Text -> f Text) -> DeleteKnownHostKeys -> f DeleteKnownHostKeys
deleteKnownHostKeys_instanceName = (DeleteKnownHostKeys -> Text)
-> (DeleteKnownHostKeys -> Text -> DeleteKnownHostKeys)
-> Lens DeleteKnownHostKeys DeleteKnownHostKeys Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteKnownHostKeys' {Text
instanceName :: Text
$sel:instanceName:DeleteKnownHostKeys' :: DeleteKnownHostKeys -> Text
instanceName} -> Text
instanceName) (\s :: DeleteKnownHostKeys
s@DeleteKnownHostKeys' {} Text
a -> DeleteKnownHostKeys
s {$sel:instanceName:DeleteKnownHostKeys' :: Text
instanceName = Text
a} :: DeleteKnownHostKeys)

instance Core.AWSRequest DeleteKnownHostKeys where
  type
    AWSResponse DeleteKnownHostKeys =
      DeleteKnownHostKeysResponse
  request :: DeleteKnownHostKeys -> Request DeleteKnownHostKeys
request = Service -> DeleteKnownHostKeys -> Request DeleteKnownHostKeys
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteKnownHostKeys
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteKnownHostKeys)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteKnownHostKeys))
-> Logger
-> Service
-> Proxy DeleteKnownHostKeys
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteKnownHostKeys)))
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 [Operation] -> Int -> DeleteKnownHostKeysResponse
DeleteKnownHostKeysResponse'
            (Maybe [Operation] -> Int -> DeleteKnownHostKeysResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> DeleteKnownHostKeysResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Operation]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"operations" Either String (Maybe (Maybe [Operation]))
-> Maybe [Operation] -> Either String (Maybe [Operation])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Operation]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DeleteKnownHostKeysResponse)
-> Either String Int -> Either String DeleteKnownHostKeysResponse
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 DeleteKnownHostKeys

instance Prelude.NFData DeleteKnownHostKeys

instance Core.ToHeaders DeleteKnownHostKeys where
  toHeaders :: DeleteKnownHostKeys -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteKnownHostKeys -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Lightsail_20161128.DeleteKnownHostKeys" ::
                          Prelude.ByteString
                      ),
            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 DeleteKnownHostKeys where
  toJSON :: DeleteKnownHostKeys -> Value
toJSON DeleteKnownHostKeys' {Text
instanceName :: Text
$sel:instanceName:DeleteKnownHostKeys' :: DeleteKnownHostKeys -> 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
"instanceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceName)]
      )

instance Core.ToPath DeleteKnownHostKeys where
  toPath :: DeleteKnownHostKeys -> ByteString
toPath = ByteString -> DeleteKnownHostKeys -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDeleteKnownHostKeysResponse' smart constructor.
data DeleteKnownHostKeysResponse = DeleteKnownHostKeysResponse'
  { -- | An array of objects that describe the result of the action, such as the
    -- status of the request, the timestamp of the request, and the resources
    -- affected by the request.
    DeleteKnownHostKeysResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
    -- | The response's http status code.
    DeleteKnownHostKeysResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteKnownHostKeysResponse -> DeleteKnownHostKeysResponse -> Bool
(DeleteKnownHostKeysResponse
 -> DeleteKnownHostKeysResponse -> Bool)
-> (DeleteKnownHostKeysResponse
    -> DeleteKnownHostKeysResponse -> Bool)
-> Eq DeleteKnownHostKeysResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteKnownHostKeysResponse -> DeleteKnownHostKeysResponse -> Bool
$c/= :: DeleteKnownHostKeysResponse -> DeleteKnownHostKeysResponse -> Bool
== :: DeleteKnownHostKeysResponse -> DeleteKnownHostKeysResponse -> Bool
$c== :: DeleteKnownHostKeysResponse -> DeleteKnownHostKeysResponse -> Bool
Prelude.Eq, ReadPrec [DeleteKnownHostKeysResponse]
ReadPrec DeleteKnownHostKeysResponse
Int -> ReadS DeleteKnownHostKeysResponse
ReadS [DeleteKnownHostKeysResponse]
(Int -> ReadS DeleteKnownHostKeysResponse)
-> ReadS [DeleteKnownHostKeysResponse]
-> ReadPrec DeleteKnownHostKeysResponse
-> ReadPrec [DeleteKnownHostKeysResponse]
-> Read DeleteKnownHostKeysResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteKnownHostKeysResponse]
$creadListPrec :: ReadPrec [DeleteKnownHostKeysResponse]
readPrec :: ReadPrec DeleteKnownHostKeysResponse
$creadPrec :: ReadPrec DeleteKnownHostKeysResponse
readList :: ReadS [DeleteKnownHostKeysResponse]
$creadList :: ReadS [DeleteKnownHostKeysResponse]
readsPrec :: Int -> ReadS DeleteKnownHostKeysResponse
$creadsPrec :: Int -> ReadS DeleteKnownHostKeysResponse
Prelude.Read, Int -> DeleteKnownHostKeysResponse -> ShowS
[DeleteKnownHostKeysResponse] -> ShowS
DeleteKnownHostKeysResponse -> String
(Int -> DeleteKnownHostKeysResponse -> ShowS)
-> (DeleteKnownHostKeysResponse -> String)
-> ([DeleteKnownHostKeysResponse] -> ShowS)
-> Show DeleteKnownHostKeysResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteKnownHostKeysResponse] -> ShowS
$cshowList :: [DeleteKnownHostKeysResponse] -> ShowS
show :: DeleteKnownHostKeysResponse -> String
$cshow :: DeleteKnownHostKeysResponse -> String
showsPrec :: Int -> DeleteKnownHostKeysResponse -> ShowS
$cshowsPrec :: Int -> DeleteKnownHostKeysResponse -> ShowS
Prelude.Show, (forall x.
 DeleteKnownHostKeysResponse -> Rep DeleteKnownHostKeysResponse x)
-> (forall x.
    Rep DeleteKnownHostKeysResponse x -> DeleteKnownHostKeysResponse)
-> Generic DeleteKnownHostKeysResponse
forall x.
Rep DeleteKnownHostKeysResponse x -> DeleteKnownHostKeysResponse
forall x.
DeleteKnownHostKeysResponse -> Rep DeleteKnownHostKeysResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteKnownHostKeysResponse x -> DeleteKnownHostKeysResponse
$cfrom :: forall x.
DeleteKnownHostKeysResponse -> Rep DeleteKnownHostKeysResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteKnownHostKeysResponse' 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:
--
-- 'operations', 'deleteKnownHostKeysResponse_operations' - An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
--
-- 'httpStatus', 'deleteKnownHostKeysResponse_httpStatus' - The response's http status code.
newDeleteKnownHostKeysResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteKnownHostKeysResponse
newDeleteKnownHostKeysResponse :: Int -> DeleteKnownHostKeysResponse
newDeleteKnownHostKeysResponse Int
pHttpStatus_ =
  DeleteKnownHostKeysResponse' :: Maybe [Operation] -> Int -> DeleteKnownHostKeysResponse
DeleteKnownHostKeysResponse'
    { $sel:operations:DeleteKnownHostKeysResponse' :: Maybe [Operation]
operations =
        Maybe [Operation]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteKnownHostKeysResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
deleteKnownHostKeysResponse_operations :: Lens.Lens' DeleteKnownHostKeysResponse (Prelude.Maybe [Operation])
deleteKnownHostKeysResponse_operations :: (Maybe [Operation] -> f (Maybe [Operation]))
-> DeleteKnownHostKeysResponse -> f DeleteKnownHostKeysResponse
deleteKnownHostKeysResponse_operations = (DeleteKnownHostKeysResponse -> Maybe [Operation])
-> (DeleteKnownHostKeysResponse
    -> Maybe [Operation] -> DeleteKnownHostKeysResponse)
-> Lens
     DeleteKnownHostKeysResponse
     DeleteKnownHostKeysResponse
     (Maybe [Operation])
     (Maybe [Operation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteKnownHostKeysResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:DeleteKnownHostKeysResponse' :: DeleteKnownHostKeysResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: DeleteKnownHostKeysResponse
s@DeleteKnownHostKeysResponse' {} Maybe [Operation]
a -> DeleteKnownHostKeysResponse
s {$sel:operations:DeleteKnownHostKeysResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: DeleteKnownHostKeysResponse) ((Maybe [Operation] -> f (Maybe [Operation]))
 -> DeleteKnownHostKeysResponse -> f DeleteKnownHostKeysResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
    -> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> DeleteKnownHostKeysResponse
-> f DeleteKnownHostKeysResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Operation] [Operation] [Operation] [Operation]
-> Iso
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
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 AnIso [Operation] [Operation] [Operation] [Operation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DeleteKnownHostKeysResponse