{-# 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.Proton.UpdateService
-- 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)
--
-- Edit a service description or use a spec to add and delete service
-- instances.
--
-- Existing service instances and the service pipeline /can\'t/ be edited
-- using this API. They can only be deleted.
--
-- Use the @description@ parameter to modify the description.
--
-- Edit the @spec@ parameter to add or delete instances.
module Amazonka.Proton.UpdateService
  ( -- * Creating a Request
    UpdateService (..),
    newUpdateService,

    -- * Request Lenses
    updateService_spec,
    updateService_description,
    updateService_name,

    -- * Destructuring the Response
    UpdateServiceResponse (..),
    newUpdateServiceResponse,

    -- * Response Lenses
    updateServiceResponse_httpStatus,
    updateServiceResponse_service,
  )
where

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

-- | /See:/ 'newUpdateService' smart constructor.
data UpdateService = UpdateService'
  { -- | Lists the service instances to add and the existing service instances to
    -- remain. Omit the existing service instances to delete from the list.
    -- /Don\'t/ include edits to the existing service instances or pipeline.
    -- For more information, see /Edit a service/ in the
    -- <https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-update.html AWS Proton Administrator Guide>
    -- or the
    -- <https://docs.aws.amazon.com/proton/latest/userguide/ug-svc-update.html AWS Proton User Guide>.
    UpdateService -> Maybe (Sensitive Text)
spec :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The edited service description.
    UpdateService -> Maybe (Sensitive Text)
description :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The name of the service to edit.
    UpdateService -> Text
name :: Prelude.Text
  }
  deriving (UpdateService -> UpdateService -> Bool
(UpdateService -> UpdateService -> Bool)
-> (UpdateService -> UpdateService -> Bool) -> Eq UpdateService
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateService -> UpdateService -> Bool
$c/= :: UpdateService -> UpdateService -> Bool
== :: UpdateService -> UpdateService -> Bool
$c== :: UpdateService -> UpdateService -> Bool
Prelude.Eq, Int -> UpdateService -> ShowS
[UpdateService] -> ShowS
UpdateService -> String
(Int -> UpdateService -> ShowS)
-> (UpdateService -> String)
-> ([UpdateService] -> ShowS)
-> Show UpdateService
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateService] -> ShowS
$cshowList :: [UpdateService] -> ShowS
show :: UpdateService -> String
$cshow :: UpdateService -> String
showsPrec :: Int -> UpdateService -> ShowS
$cshowsPrec :: Int -> UpdateService -> ShowS
Prelude.Show, (forall x. UpdateService -> Rep UpdateService x)
-> (forall x. Rep UpdateService x -> UpdateService)
-> Generic UpdateService
forall x. Rep UpdateService x -> UpdateService
forall x. UpdateService -> Rep UpdateService x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateService x -> UpdateService
$cfrom :: forall x. UpdateService -> Rep UpdateService x
Prelude.Generic)

-- |
-- Create a value of 'UpdateService' 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:
--
-- 'spec', 'updateService_spec' - Lists the service instances to add and the existing service instances to
-- remain. Omit the existing service instances to delete from the list.
-- /Don\'t/ include edits to the existing service instances or pipeline.
-- For more information, see /Edit a service/ in the
-- <https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-update.html AWS Proton Administrator Guide>
-- or the
-- <https://docs.aws.amazon.com/proton/latest/userguide/ug-svc-update.html AWS Proton User Guide>.
--
-- 'description', 'updateService_description' - The edited service description.
--
-- 'name', 'updateService_name' - The name of the service to edit.
newUpdateService ::
  -- | 'name'
  Prelude.Text ->
  UpdateService
newUpdateService :: Text -> UpdateService
newUpdateService Text
pName_ =
  UpdateService' :: Maybe (Sensitive Text)
-> Maybe (Sensitive Text) -> Text -> UpdateService
UpdateService'
    { $sel:spec:UpdateService' :: Maybe (Sensitive Text)
spec = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateService' :: Maybe (Sensitive Text)
description = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateService' :: Text
name = Text
pName_
    }

-- | Lists the service instances to add and the existing service instances to
-- remain. Omit the existing service instances to delete from the list.
-- /Don\'t/ include edits to the existing service instances or pipeline.
-- For more information, see /Edit a service/ in the
-- <https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-update.html AWS Proton Administrator Guide>
-- or the
-- <https://docs.aws.amazon.com/proton/latest/userguide/ug-svc-update.html AWS Proton User Guide>.
updateService_spec :: Lens.Lens' UpdateService (Prelude.Maybe Prelude.Text)
updateService_spec :: (Maybe Text -> f (Maybe Text)) -> UpdateService -> f UpdateService
updateService_spec = (UpdateService -> Maybe (Sensitive Text))
-> (UpdateService -> Maybe (Sensitive Text) -> UpdateService)
-> Lens
     UpdateService
     UpdateService
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateService' {Maybe (Sensitive Text)
spec :: Maybe (Sensitive Text)
$sel:spec:UpdateService' :: UpdateService -> Maybe (Sensitive Text)
spec} -> Maybe (Sensitive Text)
spec) (\s :: UpdateService
s@UpdateService' {} Maybe (Sensitive Text)
a -> UpdateService
s {$sel:spec:UpdateService' :: Maybe (Sensitive Text)
spec = Maybe (Sensitive Text)
a} :: UpdateService) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> UpdateService -> f UpdateService)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> UpdateService
-> f UpdateService
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The edited service description.
updateService_description :: Lens.Lens' UpdateService (Prelude.Maybe Prelude.Text)
updateService_description :: (Maybe Text -> f (Maybe Text)) -> UpdateService -> f UpdateService
updateService_description = (UpdateService -> Maybe (Sensitive Text))
-> (UpdateService -> Maybe (Sensitive Text) -> UpdateService)
-> Lens
     UpdateService
     UpdateService
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateService' {Maybe (Sensitive Text)
description :: Maybe (Sensitive Text)
$sel:description:UpdateService' :: UpdateService -> Maybe (Sensitive Text)
description} -> Maybe (Sensitive Text)
description) (\s :: UpdateService
s@UpdateService' {} Maybe (Sensitive Text)
a -> UpdateService
s {$sel:description:UpdateService' :: Maybe (Sensitive Text)
description = Maybe (Sensitive Text)
a} :: UpdateService) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> UpdateService -> f UpdateService)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> UpdateService
-> f UpdateService
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The name of the service to edit.
updateService_name :: Lens.Lens' UpdateService Prelude.Text
updateService_name :: (Text -> f Text) -> UpdateService -> f UpdateService
updateService_name = (UpdateService -> Text)
-> (UpdateService -> Text -> UpdateService)
-> Lens UpdateService UpdateService Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateService' {Text
name :: Text
$sel:name:UpdateService' :: UpdateService -> Text
name} -> Text
name) (\s :: UpdateService
s@UpdateService' {} Text
a -> UpdateService
s {$sel:name:UpdateService' :: Text
name = Text
a} :: UpdateService)

instance Core.AWSRequest UpdateService where
  type
    AWSResponse UpdateService =
      UpdateServiceResponse
  request :: UpdateService -> Request UpdateService
request = Service -> UpdateService -> Request UpdateService
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateService
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateService)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateService))
-> Logger
-> Service
-> Proxy UpdateService
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateService)))
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 ->
          Int -> Service -> UpdateServiceResponse
UpdateServiceResponse'
            (Int -> Service -> UpdateServiceResponse)
-> Either String Int
-> Either String (Service -> UpdateServiceResponse)
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))
            Either String (Service -> UpdateServiceResponse)
-> Either String Service -> Either String UpdateServiceResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Service
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"service")
      )

instance Prelude.Hashable UpdateService

instance Prelude.NFData UpdateService

instance Core.ToHeaders UpdateService where
  toHeaders :: UpdateService -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateService -> 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
"AwsProton20200720.UpdateService" ::
                          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 UpdateService where
  toJSON :: UpdateService -> Value
toJSON UpdateService' {Maybe (Sensitive Text)
Text
name :: Text
description :: Maybe (Sensitive Text)
spec :: Maybe (Sensitive Text)
$sel:name:UpdateService' :: UpdateService -> Text
$sel:description:UpdateService' :: UpdateService -> Maybe (Sensitive Text)
$sel:spec:UpdateService' :: UpdateService -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"spec" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
spec,
            (Text
"description" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
description,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )

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

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

-- | /See:/ 'newUpdateServiceResponse' smart constructor.
data UpdateServiceResponse = UpdateServiceResponse'
  { -- | The response's http status code.
    UpdateServiceResponse -> Int
httpStatus :: Prelude.Int,
    -- | The service detail data that\'s returned by AWS Proton.
    UpdateServiceResponse -> Service
service :: Service
  }
  deriving (UpdateServiceResponse -> UpdateServiceResponse -> Bool
(UpdateServiceResponse -> UpdateServiceResponse -> Bool)
-> (UpdateServiceResponse -> UpdateServiceResponse -> Bool)
-> Eq UpdateServiceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateServiceResponse -> UpdateServiceResponse -> Bool
$c/= :: UpdateServiceResponse -> UpdateServiceResponse -> Bool
== :: UpdateServiceResponse -> UpdateServiceResponse -> Bool
$c== :: UpdateServiceResponse -> UpdateServiceResponse -> Bool
Prelude.Eq, Int -> UpdateServiceResponse -> ShowS
[UpdateServiceResponse] -> ShowS
UpdateServiceResponse -> String
(Int -> UpdateServiceResponse -> ShowS)
-> (UpdateServiceResponse -> String)
-> ([UpdateServiceResponse] -> ShowS)
-> Show UpdateServiceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateServiceResponse] -> ShowS
$cshowList :: [UpdateServiceResponse] -> ShowS
show :: UpdateServiceResponse -> String
$cshow :: UpdateServiceResponse -> String
showsPrec :: Int -> UpdateServiceResponse -> ShowS
$cshowsPrec :: Int -> UpdateServiceResponse -> ShowS
Prelude.Show, (forall x. UpdateServiceResponse -> Rep UpdateServiceResponse x)
-> (forall x. Rep UpdateServiceResponse x -> UpdateServiceResponse)
-> Generic UpdateServiceResponse
forall x. Rep UpdateServiceResponse x -> UpdateServiceResponse
forall x. UpdateServiceResponse -> Rep UpdateServiceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateServiceResponse x -> UpdateServiceResponse
$cfrom :: forall x. UpdateServiceResponse -> Rep UpdateServiceResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateServiceResponse' 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', 'updateServiceResponse_httpStatus' - The response's http status code.
--
-- 'service', 'updateServiceResponse_service' - The service detail data that\'s returned by AWS Proton.
newUpdateServiceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'service'
  Service ->
  UpdateServiceResponse
newUpdateServiceResponse :: Int -> Service -> UpdateServiceResponse
newUpdateServiceResponse Int
pHttpStatus_ Service
pService_ =
  UpdateServiceResponse' :: Int -> Service -> UpdateServiceResponse
UpdateServiceResponse'
    { $sel:httpStatus:UpdateServiceResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:service:UpdateServiceResponse' :: Service
service = Service
pService_
    }

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

-- | The service detail data that\'s returned by AWS Proton.
updateServiceResponse_service :: Lens.Lens' UpdateServiceResponse Service
updateServiceResponse_service :: (Service -> f Service)
-> UpdateServiceResponse -> f UpdateServiceResponse
updateServiceResponse_service = (UpdateServiceResponse -> Service)
-> (UpdateServiceResponse -> Service -> UpdateServiceResponse)
-> Lens UpdateServiceResponse UpdateServiceResponse Service Service
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateServiceResponse' {Service
service :: Service
$sel:service:UpdateServiceResponse' :: UpdateServiceResponse -> Service
service} -> Service
service) (\s :: UpdateServiceResponse
s@UpdateServiceResponse' {} Service
a -> UpdateServiceResponse
s {$sel:service:UpdateServiceResponse' :: Service
service = Service
a} :: UpdateServiceResponse)

instance Prelude.NFData UpdateServiceResponse