{-# 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.WorkLink.UpdateDevicePolicyConfiguration
-- 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 the device policy configuration for the fleet.
module Amazonka.WorkLink.UpdateDevicePolicyConfiguration
  ( -- * Creating a Request
    UpdateDevicePolicyConfiguration (..),
    newUpdateDevicePolicyConfiguration,

    -- * Request Lenses
    updateDevicePolicyConfiguration_deviceCaCertificate,
    updateDevicePolicyConfiguration_fleetArn,

    -- * Destructuring the Response
    UpdateDevicePolicyConfigurationResponse (..),
    newUpdateDevicePolicyConfigurationResponse,

    -- * Response Lenses
    updateDevicePolicyConfigurationResponse_httpStatus,
  )
where

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
import Amazonka.WorkLink.Types

-- | /See:/ 'newUpdateDevicePolicyConfiguration' smart constructor.
data UpdateDevicePolicyConfiguration = UpdateDevicePolicyConfiguration'
  { -- | The certificate chain, including intermediate certificates and the root
    -- certificate authority certificate used to issue device certificates.
    UpdateDevicePolicyConfiguration -> Maybe Text
deviceCaCertificate :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the fleet.
    UpdateDevicePolicyConfiguration -> Text
fleetArn :: Prelude.Text
  }
  deriving (UpdateDevicePolicyConfiguration
-> UpdateDevicePolicyConfiguration -> Bool
(UpdateDevicePolicyConfiguration
 -> UpdateDevicePolicyConfiguration -> Bool)
-> (UpdateDevicePolicyConfiguration
    -> UpdateDevicePolicyConfiguration -> Bool)
-> Eq UpdateDevicePolicyConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDevicePolicyConfiguration
-> UpdateDevicePolicyConfiguration -> Bool
$c/= :: UpdateDevicePolicyConfiguration
-> UpdateDevicePolicyConfiguration -> Bool
== :: UpdateDevicePolicyConfiguration
-> UpdateDevicePolicyConfiguration -> Bool
$c== :: UpdateDevicePolicyConfiguration
-> UpdateDevicePolicyConfiguration -> Bool
Prelude.Eq, ReadPrec [UpdateDevicePolicyConfiguration]
ReadPrec UpdateDevicePolicyConfiguration
Int -> ReadS UpdateDevicePolicyConfiguration
ReadS [UpdateDevicePolicyConfiguration]
(Int -> ReadS UpdateDevicePolicyConfiguration)
-> ReadS [UpdateDevicePolicyConfiguration]
-> ReadPrec UpdateDevicePolicyConfiguration
-> ReadPrec [UpdateDevicePolicyConfiguration]
-> Read UpdateDevicePolicyConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDevicePolicyConfiguration]
$creadListPrec :: ReadPrec [UpdateDevicePolicyConfiguration]
readPrec :: ReadPrec UpdateDevicePolicyConfiguration
$creadPrec :: ReadPrec UpdateDevicePolicyConfiguration
readList :: ReadS [UpdateDevicePolicyConfiguration]
$creadList :: ReadS [UpdateDevicePolicyConfiguration]
readsPrec :: Int -> ReadS UpdateDevicePolicyConfiguration
$creadsPrec :: Int -> ReadS UpdateDevicePolicyConfiguration
Prelude.Read, Int -> UpdateDevicePolicyConfiguration -> ShowS
[UpdateDevicePolicyConfiguration] -> ShowS
UpdateDevicePolicyConfiguration -> String
(Int -> UpdateDevicePolicyConfiguration -> ShowS)
-> (UpdateDevicePolicyConfiguration -> String)
-> ([UpdateDevicePolicyConfiguration] -> ShowS)
-> Show UpdateDevicePolicyConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDevicePolicyConfiguration] -> ShowS
$cshowList :: [UpdateDevicePolicyConfiguration] -> ShowS
show :: UpdateDevicePolicyConfiguration -> String
$cshow :: UpdateDevicePolicyConfiguration -> String
showsPrec :: Int -> UpdateDevicePolicyConfiguration -> ShowS
$cshowsPrec :: Int -> UpdateDevicePolicyConfiguration -> ShowS
Prelude.Show, (forall x.
 UpdateDevicePolicyConfiguration
 -> Rep UpdateDevicePolicyConfiguration x)
-> (forall x.
    Rep UpdateDevicePolicyConfiguration x
    -> UpdateDevicePolicyConfiguration)
-> Generic UpdateDevicePolicyConfiguration
forall x.
Rep UpdateDevicePolicyConfiguration x
-> UpdateDevicePolicyConfiguration
forall x.
UpdateDevicePolicyConfiguration
-> Rep UpdateDevicePolicyConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateDevicePolicyConfiguration x
-> UpdateDevicePolicyConfiguration
$cfrom :: forall x.
UpdateDevicePolicyConfiguration
-> Rep UpdateDevicePolicyConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDevicePolicyConfiguration' 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:
--
-- 'deviceCaCertificate', 'updateDevicePolicyConfiguration_deviceCaCertificate' - The certificate chain, including intermediate certificates and the root
-- certificate authority certificate used to issue device certificates.
--
-- 'fleetArn', 'updateDevicePolicyConfiguration_fleetArn' - The ARN of the fleet.
newUpdateDevicePolicyConfiguration ::
  -- | 'fleetArn'
  Prelude.Text ->
  UpdateDevicePolicyConfiguration
newUpdateDevicePolicyConfiguration :: Text -> UpdateDevicePolicyConfiguration
newUpdateDevicePolicyConfiguration Text
pFleetArn_ =
  UpdateDevicePolicyConfiguration' :: Maybe Text -> Text -> UpdateDevicePolicyConfiguration
UpdateDevicePolicyConfiguration'
    { $sel:deviceCaCertificate:UpdateDevicePolicyConfiguration' :: Maybe Text
deviceCaCertificate =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fleetArn:UpdateDevicePolicyConfiguration' :: Text
fleetArn = Text
pFleetArn_
    }

-- | The certificate chain, including intermediate certificates and the root
-- certificate authority certificate used to issue device certificates.
updateDevicePolicyConfiguration_deviceCaCertificate :: Lens.Lens' UpdateDevicePolicyConfiguration (Prelude.Maybe Prelude.Text)
updateDevicePolicyConfiguration_deviceCaCertificate :: (Maybe Text -> f (Maybe Text))
-> UpdateDevicePolicyConfiguration
-> f UpdateDevicePolicyConfiguration
updateDevicePolicyConfiguration_deviceCaCertificate = (UpdateDevicePolicyConfiguration -> Maybe Text)
-> (UpdateDevicePolicyConfiguration
    -> Maybe Text -> UpdateDevicePolicyConfiguration)
-> Lens
     UpdateDevicePolicyConfiguration
     UpdateDevicePolicyConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDevicePolicyConfiguration' {Maybe Text
deviceCaCertificate :: Maybe Text
$sel:deviceCaCertificate:UpdateDevicePolicyConfiguration' :: UpdateDevicePolicyConfiguration -> Maybe Text
deviceCaCertificate} -> Maybe Text
deviceCaCertificate) (\s :: UpdateDevicePolicyConfiguration
s@UpdateDevicePolicyConfiguration' {} Maybe Text
a -> UpdateDevicePolicyConfiguration
s {$sel:deviceCaCertificate:UpdateDevicePolicyConfiguration' :: Maybe Text
deviceCaCertificate = Maybe Text
a} :: UpdateDevicePolicyConfiguration)

-- | The ARN of the fleet.
updateDevicePolicyConfiguration_fleetArn :: Lens.Lens' UpdateDevicePolicyConfiguration Prelude.Text
updateDevicePolicyConfiguration_fleetArn :: (Text -> f Text)
-> UpdateDevicePolicyConfiguration
-> f UpdateDevicePolicyConfiguration
updateDevicePolicyConfiguration_fleetArn = (UpdateDevicePolicyConfiguration -> Text)
-> (UpdateDevicePolicyConfiguration
    -> Text -> UpdateDevicePolicyConfiguration)
-> Lens
     UpdateDevicePolicyConfiguration
     UpdateDevicePolicyConfiguration
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDevicePolicyConfiguration' {Text
fleetArn :: Text
$sel:fleetArn:UpdateDevicePolicyConfiguration' :: UpdateDevicePolicyConfiguration -> Text
fleetArn} -> Text
fleetArn) (\s :: UpdateDevicePolicyConfiguration
s@UpdateDevicePolicyConfiguration' {} Text
a -> UpdateDevicePolicyConfiguration
s {$sel:fleetArn:UpdateDevicePolicyConfiguration' :: Text
fleetArn = Text
a} :: UpdateDevicePolicyConfiguration)

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

instance
  Prelude.NFData
    UpdateDevicePolicyConfiguration

instance
  Core.ToHeaders
    UpdateDevicePolicyConfiguration
  where
  toHeaders :: UpdateDevicePolicyConfiguration -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> UpdateDevicePolicyConfiguration -> 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 UpdateDevicePolicyConfiguration where
  toJSON :: UpdateDevicePolicyConfiguration -> Value
toJSON UpdateDevicePolicyConfiguration' {Maybe Text
Text
fleetArn :: Text
deviceCaCertificate :: Maybe Text
$sel:fleetArn:UpdateDevicePolicyConfiguration' :: UpdateDevicePolicyConfiguration -> Text
$sel:deviceCaCertificate:UpdateDevicePolicyConfiguration' :: UpdateDevicePolicyConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DeviceCaCertificate" 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
deviceCaCertificate,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FleetArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fleetArn)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    UpdateDevicePolicyConfigurationResponse