{-# 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.CodeStarConnections.UpdateHost
-- 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)
--
-- Updates a specified host with the provided configurations.
module Amazonka.CodeStarConnections.UpdateHost
  ( -- * Creating a Request
    UpdateHost (..),
    newUpdateHost,

    -- * Request Lenses
    updateHost_providerEndpoint,
    updateHost_vpcConfiguration,
    updateHost_hostArn,

    -- * Destructuring the Response
    UpdateHostResponse (..),
    newUpdateHostResponse,

    -- * Response Lenses
    updateHostResponse_httpStatus,
  )
where

import Amazonka.CodeStarConnections.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:/ 'newUpdateHost' smart constructor.
data UpdateHost = UpdateHost'
  { -- | The URL or endpoint of the host to be updated.
    UpdateHost -> Maybe Text
providerEndpoint :: Prelude.Maybe Prelude.Text,
    -- | The VPC configuration of the host to be updated. A VPC must be
    -- configured and the infrastructure to be represented by the host must
    -- already be connected to the VPC.
    UpdateHost -> Maybe VpcConfiguration
vpcConfiguration :: Prelude.Maybe VpcConfiguration,
    -- | The Amazon Resource Name (ARN) of the host to be updated.
    UpdateHost -> Text
hostArn :: Prelude.Text
  }
  deriving (UpdateHost -> UpdateHost -> Bool
(UpdateHost -> UpdateHost -> Bool)
-> (UpdateHost -> UpdateHost -> Bool) -> Eq UpdateHost
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateHost -> UpdateHost -> Bool
$c/= :: UpdateHost -> UpdateHost -> Bool
== :: UpdateHost -> UpdateHost -> Bool
$c== :: UpdateHost -> UpdateHost -> Bool
Prelude.Eq, ReadPrec [UpdateHost]
ReadPrec UpdateHost
Int -> ReadS UpdateHost
ReadS [UpdateHost]
(Int -> ReadS UpdateHost)
-> ReadS [UpdateHost]
-> ReadPrec UpdateHost
-> ReadPrec [UpdateHost]
-> Read UpdateHost
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateHost]
$creadListPrec :: ReadPrec [UpdateHost]
readPrec :: ReadPrec UpdateHost
$creadPrec :: ReadPrec UpdateHost
readList :: ReadS [UpdateHost]
$creadList :: ReadS [UpdateHost]
readsPrec :: Int -> ReadS UpdateHost
$creadsPrec :: Int -> ReadS UpdateHost
Prelude.Read, Int -> UpdateHost -> ShowS
[UpdateHost] -> ShowS
UpdateHost -> String
(Int -> UpdateHost -> ShowS)
-> (UpdateHost -> String)
-> ([UpdateHost] -> ShowS)
-> Show UpdateHost
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateHost] -> ShowS
$cshowList :: [UpdateHost] -> ShowS
show :: UpdateHost -> String
$cshow :: UpdateHost -> String
showsPrec :: Int -> UpdateHost -> ShowS
$cshowsPrec :: Int -> UpdateHost -> ShowS
Prelude.Show, (forall x. UpdateHost -> Rep UpdateHost x)
-> (forall x. Rep UpdateHost x -> UpdateHost) -> Generic UpdateHost
forall x. Rep UpdateHost x -> UpdateHost
forall x. UpdateHost -> Rep UpdateHost x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateHost x -> UpdateHost
$cfrom :: forall x. UpdateHost -> Rep UpdateHost x
Prelude.Generic)

-- |
-- Create a value of 'UpdateHost' 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:
--
-- 'providerEndpoint', 'updateHost_providerEndpoint' - The URL or endpoint of the host to be updated.
--
-- 'vpcConfiguration', 'updateHost_vpcConfiguration' - The VPC configuration of the host to be updated. A VPC must be
-- configured and the infrastructure to be represented by the host must
-- already be connected to the VPC.
--
-- 'hostArn', 'updateHost_hostArn' - The Amazon Resource Name (ARN) of the host to be updated.
newUpdateHost ::
  -- | 'hostArn'
  Prelude.Text ->
  UpdateHost
newUpdateHost :: Text -> UpdateHost
newUpdateHost Text
pHostArn_ =
  UpdateHost' :: Maybe Text -> Maybe VpcConfiguration -> Text -> UpdateHost
UpdateHost'
    { $sel:providerEndpoint:UpdateHost' :: Maybe Text
providerEndpoint = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:vpcConfiguration:UpdateHost' :: Maybe VpcConfiguration
vpcConfiguration = Maybe VpcConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:hostArn:UpdateHost' :: Text
hostArn = Text
pHostArn_
    }

-- | The URL or endpoint of the host to be updated.
updateHost_providerEndpoint :: Lens.Lens' UpdateHost (Prelude.Maybe Prelude.Text)
updateHost_providerEndpoint :: (Maybe Text -> f (Maybe Text)) -> UpdateHost -> f UpdateHost
updateHost_providerEndpoint = (UpdateHost -> Maybe Text)
-> (UpdateHost -> Maybe Text -> UpdateHost)
-> Lens UpdateHost UpdateHost (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateHost' {Maybe Text
providerEndpoint :: Maybe Text
$sel:providerEndpoint:UpdateHost' :: UpdateHost -> Maybe Text
providerEndpoint} -> Maybe Text
providerEndpoint) (\s :: UpdateHost
s@UpdateHost' {} Maybe Text
a -> UpdateHost
s {$sel:providerEndpoint:UpdateHost' :: Maybe Text
providerEndpoint = Maybe Text
a} :: UpdateHost)

-- | The VPC configuration of the host to be updated. A VPC must be
-- configured and the infrastructure to be represented by the host must
-- already be connected to the VPC.
updateHost_vpcConfiguration :: Lens.Lens' UpdateHost (Prelude.Maybe VpcConfiguration)
updateHost_vpcConfiguration :: (Maybe VpcConfiguration -> f (Maybe VpcConfiguration))
-> UpdateHost -> f UpdateHost
updateHost_vpcConfiguration = (UpdateHost -> Maybe VpcConfiguration)
-> (UpdateHost -> Maybe VpcConfiguration -> UpdateHost)
-> Lens
     UpdateHost
     UpdateHost
     (Maybe VpcConfiguration)
     (Maybe VpcConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateHost' {Maybe VpcConfiguration
vpcConfiguration :: Maybe VpcConfiguration
$sel:vpcConfiguration:UpdateHost' :: UpdateHost -> Maybe VpcConfiguration
vpcConfiguration} -> Maybe VpcConfiguration
vpcConfiguration) (\s :: UpdateHost
s@UpdateHost' {} Maybe VpcConfiguration
a -> UpdateHost
s {$sel:vpcConfiguration:UpdateHost' :: Maybe VpcConfiguration
vpcConfiguration = Maybe VpcConfiguration
a} :: UpdateHost)

-- | The Amazon Resource Name (ARN) of the host to be updated.
updateHost_hostArn :: Lens.Lens' UpdateHost Prelude.Text
updateHost_hostArn :: (Text -> f Text) -> UpdateHost -> f UpdateHost
updateHost_hostArn = (UpdateHost -> Text)
-> (UpdateHost -> Text -> UpdateHost)
-> Lens UpdateHost UpdateHost Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateHost' {Text
hostArn :: Text
$sel:hostArn:UpdateHost' :: UpdateHost -> Text
hostArn} -> Text
hostArn) (\s :: UpdateHost
s@UpdateHost' {} Text
a -> UpdateHost
s {$sel:hostArn:UpdateHost' :: Text
hostArn = Text
a} :: UpdateHost)

instance Core.AWSRequest UpdateHost where
  type AWSResponse UpdateHost = UpdateHostResponse
  request :: UpdateHost -> Request UpdateHost
request = Service -> UpdateHost -> Request UpdateHost
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateHost
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateHost)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse UpdateHost))
-> Logger
-> Service
-> Proxy UpdateHost
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateHost)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateHostResponse
UpdateHostResponse'
            (Int -> UpdateHostResponse)
-> Either String Int -> Either String UpdateHostResponse
forall (f :: * -> *) a b. Functor 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 UpdateHost

instance Prelude.NFData UpdateHost

instance Core.ToHeaders UpdateHost where
  toHeaders :: UpdateHost -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateHost -> 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
"com.amazonaws.codestar.connections.CodeStar_connections_20191201.UpdateHost" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateHost where
  toJSON :: UpdateHost -> Value
toJSON UpdateHost' {Maybe Text
Maybe VpcConfiguration
Text
hostArn :: Text
vpcConfiguration :: Maybe VpcConfiguration
providerEndpoint :: Maybe Text
$sel:hostArn:UpdateHost' :: UpdateHost -> Text
$sel:vpcConfiguration:UpdateHost' :: UpdateHost -> Maybe VpcConfiguration
$sel:providerEndpoint:UpdateHost' :: UpdateHost -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ProviderEndpoint" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
providerEndpoint,
            (Text
"VpcConfiguration" Text -> VpcConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (VpcConfiguration -> Pair) -> Maybe VpcConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VpcConfiguration
vpcConfiguration,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"HostArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
hostArn)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateHostResponse' 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', 'updateHostResponse_httpStatus' - The response's http status code.
newUpdateHostResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateHostResponse
newUpdateHostResponse :: Int -> UpdateHostResponse
newUpdateHostResponse Int
pHttpStatus_ =
  UpdateHostResponse' :: Int -> UpdateHostResponse
UpdateHostResponse' {$sel:httpStatus:UpdateHostResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData UpdateHostResponse