{-# 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.DevOpsGuru.UpdateServiceIntegration
-- 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)
--
-- Enables or disables integration with a service that can be integrated
-- with DevOps Guru. The one service that can be integrated with DevOps
-- Guru is AWS Systems Manager, which can be used to create an OpsItem for
-- each generated insight.
module Amazonka.DevOpsGuru.UpdateServiceIntegration
  ( -- * Creating a Request
    UpdateServiceIntegration (..),
    newUpdateServiceIntegration,

    -- * Request Lenses
    updateServiceIntegration_serviceIntegration,

    -- * Destructuring the Response
    UpdateServiceIntegrationResponse (..),
    newUpdateServiceIntegrationResponse,

    -- * Response Lenses
    updateServiceIntegrationResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DevOpsGuru.Types
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:/ 'newUpdateServiceIntegration' smart constructor.
data UpdateServiceIntegration = UpdateServiceIntegration'
  { -- | An @IntegratedServiceConfig@ object used to specify the integrated
    -- service you want to update, and whether you want to update it to enabled
    -- or disabled.
    UpdateServiceIntegration -> UpdateServiceIntegrationConfig
serviceIntegration :: UpdateServiceIntegrationConfig
  }
  deriving (UpdateServiceIntegration -> UpdateServiceIntegration -> Bool
(UpdateServiceIntegration -> UpdateServiceIntegration -> Bool)
-> (UpdateServiceIntegration -> UpdateServiceIntegration -> Bool)
-> Eq UpdateServiceIntegration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateServiceIntegration -> UpdateServiceIntegration -> Bool
$c/= :: UpdateServiceIntegration -> UpdateServiceIntegration -> Bool
== :: UpdateServiceIntegration -> UpdateServiceIntegration -> Bool
$c== :: UpdateServiceIntegration -> UpdateServiceIntegration -> Bool
Prelude.Eq, ReadPrec [UpdateServiceIntegration]
ReadPrec UpdateServiceIntegration
Int -> ReadS UpdateServiceIntegration
ReadS [UpdateServiceIntegration]
(Int -> ReadS UpdateServiceIntegration)
-> ReadS [UpdateServiceIntegration]
-> ReadPrec UpdateServiceIntegration
-> ReadPrec [UpdateServiceIntegration]
-> Read UpdateServiceIntegration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateServiceIntegration]
$creadListPrec :: ReadPrec [UpdateServiceIntegration]
readPrec :: ReadPrec UpdateServiceIntegration
$creadPrec :: ReadPrec UpdateServiceIntegration
readList :: ReadS [UpdateServiceIntegration]
$creadList :: ReadS [UpdateServiceIntegration]
readsPrec :: Int -> ReadS UpdateServiceIntegration
$creadsPrec :: Int -> ReadS UpdateServiceIntegration
Prelude.Read, Int -> UpdateServiceIntegration -> ShowS
[UpdateServiceIntegration] -> ShowS
UpdateServiceIntegration -> String
(Int -> UpdateServiceIntegration -> ShowS)
-> (UpdateServiceIntegration -> String)
-> ([UpdateServiceIntegration] -> ShowS)
-> Show UpdateServiceIntegration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateServiceIntegration] -> ShowS
$cshowList :: [UpdateServiceIntegration] -> ShowS
show :: UpdateServiceIntegration -> String
$cshow :: UpdateServiceIntegration -> String
showsPrec :: Int -> UpdateServiceIntegration -> ShowS
$cshowsPrec :: Int -> UpdateServiceIntegration -> ShowS
Prelude.Show, (forall x.
 UpdateServiceIntegration -> Rep UpdateServiceIntegration x)
-> (forall x.
    Rep UpdateServiceIntegration x -> UpdateServiceIntegration)
-> Generic UpdateServiceIntegration
forall x.
Rep UpdateServiceIntegration x -> UpdateServiceIntegration
forall x.
UpdateServiceIntegration -> Rep UpdateServiceIntegration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateServiceIntegration x -> UpdateServiceIntegration
$cfrom :: forall x.
UpdateServiceIntegration -> Rep UpdateServiceIntegration x
Prelude.Generic)

-- |
-- Create a value of 'UpdateServiceIntegration' 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:
--
-- 'serviceIntegration', 'updateServiceIntegration_serviceIntegration' - An @IntegratedServiceConfig@ object used to specify the integrated
-- service you want to update, and whether you want to update it to enabled
-- or disabled.
newUpdateServiceIntegration ::
  -- | 'serviceIntegration'
  UpdateServiceIntegrationConfig ->
  UpdateServiceIntegration
newUpdateServiceIntegration :: UpdateServiceIntegrationConfig -> UpdateServiceIntegration
newUpdateServiceIntegration UpdateServiceIntegrationConfig
pServiceIntegration_ =
  UpdateServiceIntegration' :: UpdateServiceIntegrationConfig -> UpdateServiceIntegration
UpdateServiceIntegration'
    { $sel:serviceIntegration:UpdateServiceIntegration' :: UpdateServiceIntegrationConfig
serviceIntegration =
        UpdateServiceIntegrationConfig
pServiceIntegration_
    }

-- | An @IntegratedServiceConfig@ object used to specify the integrated
-- service you want to update, and whether you want to update it to enabled
-- or disabled.
updateServiceIntegration_serviceIntegration :: Lens.Lens' UpdateServiceIntegration UpdateServiceIntegrationConfig
updateServiceIntegration_serviceIntegration :: (UpdateServiceIntegrationConfig
 -> f UpdateServiceIntegrationConfig)
-> UpdateServiceIntegration -> f UpdateServiceIntegration
updateServiceIntegration_serviceIntegration = (UpdateServiceIntegration -> UpdateServiceIntegrationConfig)
-> (UpdateServiceIntegration
    -> UpdateServiceIntegrationConfig -> UpdateServiceIntegration)
-> Lens
     UpdateServiceIntegration
     UpdateServiceIntegration
     UpdateServiceIntegrationConfig
     UpdateServiceIntegrationConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateServiceIntegration' {UpdateServiceIntegrationConfig
serviceIntegration :: UpdateServiceIntegrationConfig
$sel:serviceIntegration:UpdateServiceIntegration' :: UpdateServiceIntegration -> UpdateServiceIntegrationConfig
serviceIntegration} -> UpdateServiceIntegrationConfig
serviceIntegration) (\s :: UpdateServiceIntegration
s@UpdateServiceIntegration' {} UpdateServiceIntegrationConfig
a -> UpdateServiceIntegration
s {$sel:serviceIntegration:UpdateServiceIntegration' :: UpdateServiceIntegrationConfig
serviceIntegration = UpdateServiceIntegrationConfig
a} :: UpdateServiceIntegration)

instance Core.AWSRequest UpdateServiceIntegration where
  type
    AWSResponse UpdateServiceIntegration =
      UpdateServiceIntegrationResponse
  request :: UpdateServiceIntegration -> Request UpdateServiceIntegration
request = Service
-> UpdateServiceIntegration -> Request UpdateServiceIntegration
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateServiceIntegration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateServiceIntegration)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateServiceIntegration))
-> Logger
-> Service
-> Proxy UpdateServiceIntegration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateServiceIntegration)))
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 -> UpdateServiceIntegrationResponse
UpdateServiceIntegrationResponse'
            (Int -> UpdateServiceIntegrationResponse)
-> Either String Int
-> Either String UpdateServiceIntegrationResponse
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 UpdateServiceIntegration

instance Prelude.NFData UpdateServiceIntegration

instance Core.ToHeaders UpdateServiceIntegration where
  toHeaders :: UpdateServiceIntegration -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateServiceIntegration -> 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 UpdateServiceIntegration where
  toJSON :: UpdateServiceIntegration -> Value
toJSON UpdateServiceIntegration' {UpdateServiceIntegrationConfig
serviceIntegration :: UpdateServiceIntegrationConfig
$sel:serviceIntegration:UpdateServiceIntegration' :: UpdateServiceIntegration -> UpdateServiceIntegrationConfig
..} =
    [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
"ServiceIntegration" Text -> UpdateServiceIntegrationConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= UpdateServiceIntegrationConfig
serviceIntegration)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    UpdateServiceIntegrationResponse