{-# 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.CloudControl.UpdateResource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the specified property values in the resource.
--
-- You specify your resource property updates as a list of patch operations
-- contained in a JSON patch document that adheres to the
-- <https://datatracker.ietf.org/doc/html/rfc6902 RFC 6902 - JavaScript Object Notation (JSON) Patch>
-- standard.
--
-- For details on how Cloud Control API performs resource update
-- operations, see
-- <https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations-update.html Updating a resource>
-- in the /Amazon Web Services Cloud Control API User Guide/.
--
-- After you have initiated a resource update request, you can monitor the
-- progress of your request by calling
-- <https://docs.aws.amazon.com/cloudcontrolapi/latest/APIReference/API_GetResourceRequestStatus.html GetResourceRequestStatus>
-- using the @RequestToken@ of the @ProgressEvent@ returned by
-- @UpdateResource@.
--
-- For more information about the properties of a specific resource, refer
-- to the related topic for the resource in the
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html Resource and property types reference>
-- in the /CloudFormation Users Guide/.
module Amazonka.CloudControl.UpdateResource
  ( -- * Creating a Request
    UpdateResource (..),
    newUpdateResource,

    -- * Request Lenses
    updateResource_clientToken,
    updateResource_roleArn,
    updateResource_typeVersionId,
    updateResource_typeName,
    updateResource_identifier,
    updateResource_patchDocument,

    -- * Destructuring the Response
    UpdateResourceResponse (..),
    newUpdateResourceResponse,

    -- * Response Lenses
    updateResourceResponse_progressEvent,
    updateResourceResponse_httpStatus,
  )
where

import Amazonka.CloudControl.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateResource' smart constructor.
data UpdateResource = UpdateResource'
  { -- | A unique identifier to ensure the idempotency of the resource request.
    -- As a best practice, specify this token to ensure idempotency, so that
    -- Amazon Web Services Cloud Control API can accurately distinguish between
    -- request retries and new resource requests. You might retry a resource
    -- request to ensure that it was successfully received.
    --
    -- A client token is valid for 36 hours once used. After that, a resource
    -- request with the same client token is treated as a new request.
    --
    -- If you do not specify a client token, one is generated for inclusion in
    -- the request.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations.html#resource-operations-idempotency Ensuring resource operation requests are unique>
    -- in the /Amazon Web Services Cloud Control API User Guide/.
    UpdateResource -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the Identity and Access Management
    -- (IAM) role for Cloud Control API to use when performing this resource
    -- operation. The role specified must have the permissions required for
    -- this operation. The necessary permissions for each event handler are
    -- defined in the
    -- @ @<https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html#schema-properties-handlers handlers>@ @
    -- section of the
    -- <https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html resource type definition schema>.
    --
    -- If you do not specify a role, Cloud Control API uses a temporary session
    -- created using your Amazon Web Services user credentials.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations.html#resource-operations-permissions Specifying credentials>
    -- in the /Amazon Web Services Cloud Control API User Guide/.
    UpdateResource -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | For private resource types, the type version to use in this resource
    -- operation. If you do not specify a resource version, CloudFormation uses
    -- the default version.
    UpdateResource -> Maybe Text
typeVersionId :: Prelude.Maybe Prelude.Text,
    -- | The name of the resource type.
    UpdateResource -> Text
typeName :: Prelude.Text,
    -- | The identifier for the resource.
    --
    -- You can specify the primary identifier, or any secondary identifier
    -- defined for the resource type in its resource schema. You can only
    -- specify one identifier. Primary identifiers can be specified as a string
    -- or JSON; secondary identifiers must be specified as JSON.
    --
    -- For compound primary identifiers (that is, one that consists of multiple
    -- resource properties strung together), to specify the primary identifier
    -- as a string, list the property values /in the order they are specified/
    -- in the primary identifier definition, separated by @|@.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-identifier.html Identifying resources>
    -- in the /Amazon Web Services Cloud Control API User Guide/.
    UpdateResource -> Text
identifier :: Prelude.Text,
    -- | A JavaScript Object Notation (JSON) document listing the patch
    -- operations that represent the updates to apply to the current resource
    -- properties. For details, see
    -- <https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations-update.html#resource-operations-update-patch Composing the patch document>
    -- in the /Amazon Web Services Cloud Control API User Guide/.
    UpdateResource -> Sensitive Text
patchDocument :: Data.Sensitive Prelude.Text
  }
  deriving (UpdateResource -> UpdateResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateResource -> UpdateResource -> Bool
$c/= :: UpdateResource -> UpdateResource -> Bool
== :: UpdateResource -> UpdateResource -> Bool
$c== :: UpdateResource -> UpdateResource -> Bool
Prelude.Eq, Int -> UpdateResource -> ShowS
[UpdateResource] -> ShowS
UpdateResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateResource] -> ShowS
$cshowList :: [UpdateResource] -> ShowS
show :: UpdateResource -> String
$cshow :: UpdateResource -> String
showsPrec :: Int -> UpdateResource -> ShowS
$cshowsPrec :: Int -> UpdateResource -> ShowS
Prelude.Show, forall x. Rep UpdateResource x -> UpdateResource
forall x. UpdateResource -> Rep UpdateResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateResource x -> UpdateResource
$cfrom :: forall x. UpdateResource -> Rep UpdateResource x
Prelude.Generic)

-- |
-- Create a value of 'UpdateResource' 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:
--
-- 'clientToken', 'updateResource_clientToken' - A unique identifier to ensure the idempotency of the resource request.
-- As a best practice, specify this token to ensure idempotency, so that
-- Amazon Web Services Cloud Control API can accurately distinguish between
-- request retries and new resource requests. You might retry a resource
-- request to ensure that it was successfully received.
--
-- A client token is valid for 36 hours once used. After that, a resource
-- request with the same client token is treated as a new request.
--
-- If you do not specify a client token, one is generated for inclusion in
-- the request.
--
-- For more information, see
-- <https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations.html#resource-operations-idempotency Ensuring resource operation requests are unique>
-- in the /Amazon Web Services Cloud Control API User Guide/.
--
-- 'roleArn', 'updateResource_roleArn' - The Amazon Resource Name (ARN) of the Identity and Access Management
-- (IAM) role for Cloud Control API to use when performing this resource
-- operation. The role specified must have the permissions required for
-- this operation. The necessary permissions for each event handler are
-- defined in the
-- @ @<https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html#schema-properties-handlers handlers>@ @
-- section of the
-- <https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html resource type definition schema>.
--
-- If you do not specify a role, Cloud Control API uses a temporary session
-- created using your Amazon Web Services user credentials.
--
-- For more information, see
-- <https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations.html#resource-operations-permissions Specifying credentials>
-- in the /Amazon Web Services Cloud Control API User Guide/.
--
-- 'typeVersionId', 'updateResource_typeVersionId' - For private resource types, the type version to use in this resource
-- operation. If you do not specify a resource version, CloudFormation uses
-- the default version.
--
-- 'typeName', 'updateResource_typeName' - The name of the resource type.
--
-- 'identifier', 'updateResource_identifier' - The identifier for the resource.
--
-- You can specify the primary identifier, or any secondary identifier
-- defined for the resource type in its resource schema. You can only
-- specify one identifier. Primary identifiers can be specified as a string
-- or JSON; secondary identifiers must be specified as JSON.
--
-- For compound primary identifiers (that is, one that consists of multiple
-- resource properties strung together), to specify the primary identifier
-- as a string, list the property values /in the order they are specified/
-- in the primary identifier definition, separated by @|@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-identifier.html Identifying resources>
-- in the /Amazon Web Services Cloud Control API User Guide/.
--
-- 'patchDocument', 'updateResource_patchDocument' - A JavaScript Object Notation (JSON) document listing the patch
-- operations that represent the updates to apply to the current resource
-- properties. For details, see
-- <https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations-update.html#resource-operations-update-patch Composing the patch document>
-- in the /Amazon Web Services Cloud Control API User Guide/.
newUpdateResource ::
  -- | 'typeName'
  Prelude.Text ->
  -- | 'identifier'
  Prelude.Text ->
  -- | 'patchDocument'
  Prelude.Text ->
  UpdateResource
newUpdateResource :: Text -> Text -> Text -> UpdateResource
newUpdateResource
  Text
pTypeName_
  Text
pIdentifier_
  Text
pPatchDocument_ =
    UpdateResource'
      { $sel:clientToken:UpdateResource' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
        $sel:roleArn:UpdateResource' :: Maybe Text
roleArn = forall a. Maybe a
Prelude.Nothing,
        $sel:typeVersionId:UpdateResource' :: Maybe Text
typeVersionId = forall a. Maybe a
Prelude.Nothing,
        $sel:typeName:UpdateResource' :: Text
typeName = Text
pTypeName_,
        $sel:identifier:UpdateResource' :: Text
identifier = Text
pIdentifier_,
        $sel:patchDocument:UpdateResource' :: Sensitive Text
patchDocument =
          forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pPatchDocument_
      }

-- | A unique identifier to ensure the idempotency of the resource request.
-- As a best practice, specify this token to ensure idempotency, so that
-- Amazon Web Services Cloud Control API can accurately distinguish between
-- request retries and new resource requests. You might retry a resource
-- request to ensure that it was successfully received.
--
-- A client token is valid for 36 hours once used. After that, a resource
-- request with the same client token is treated as a new request.
--
-- If you do not specify a client token, one is generated for inclusion in
-- the request.
--
-- For more information, see
-- <https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations.html#resource-operations-idempotency Ensuring resource operation requests are unique>
-- in the /Amazon Web Services Cloud Control API User Guide/.
updateResource_clientToken :: Lens.Lens' UpdateResource (Prelude.Maybe Prelude.Text)
updateResource_clientToken :: Lens' UpdateResource (Maybe Text)
updateResource_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResource' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:UpdateResource' :: UpdateResource -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: UpdateResource
s@UpdateResource' {} Maybe Text
a -> UpdateResource
s {$sel:clientToken:UpdateResource' :: Maybe Text
clientToken = Maybe Text
a} :: UpdateResource)

-- | The Amazon Resource Name (ARN) of the Identity and Access Management
-- (IAM) role for Cloud Control API to use when performing this resource
-- operation. The role specified must have the permissions required for
-- this operation. The necessary permissions for each event handler are
-- defined in the
-- @ @<https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html#schema-properties-handlers handlers>@ @
-- section of the
-- <https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html resource type definition schema>.
--
-- If you do not specify a role, Cloud Control API uses a temporary session
-- created using your Amazon Web Services user credentials.
--
-- For more information, see
-- <https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations.html#resource-operations-permissions Specifying credentials>
-- in the /Amazon Web Services Cloud Control API User Guide/.
updateResource_roleArn :: Lens.Lens' UpdateResource (Prelude.Maybe Prelude.Text)
updateResource_roleArn :: Lens' UpdateResource (Maybe Text)
updateResource_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResource' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:UpdateResource' :: UpdateResource -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: UpdateResource
s@UpdateResource' {} Maybe Text
a -> UpdateResource
s {$sel:roleArn:UpdateResource' :: Maybe Text
roleArn = Maybe Text
a} :: UpdateResource)

-- | For private resource types, the type version to use in this resource
-- operation. If you do not specify a resource version, CloudFormation uses
-- the default version.
updateResource_typeVersionId :: Lens.Lens' UpdateResource (Prelude.Maybe Prelude.Text)
updateResource_typeVersionId :: Lens' UpdateResource (Maybe Text)
updateResource_typeVersionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResource' {Maybe Text
typeVersionId :: Maybe Text
$sel:typeVersionId:UpdateResource' :: UpdateResource -> Maybe Text
typeVersionId} -> Maybe Text
typeVersionId) (\s :: UpdateResource
s@UpdateResource' {} Maybe Text
a -> UpdateResource
s {$sel:typeVersionId:UpdateResource' :: Maybe Text
typeVersionId = Maybe Text
a} :: UpdateResource)

-- | The name of the resource type.
updateResource_typeName :: Lens.Lens' UpdateResource Prelude.Text
updateResource_typeName :: Lens' UpdateResource Text
updateResource_typeName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResource' {Text
typeName :: Text
$sel:typeName:UpdateResource' :: UpdateResource -> Text
typeName} -> Text
typeName) (\s :: UpdateResource
s@UpdateResource' {} Text
a -> UpdateResource
s {$sel:typeName:UpdateResource' :: Text
typeName = Text
a} :: UpdateResource)

-- | The identifier for the resource.
--
-- You can specify the primary identifier, or any secondary identifier
-- defined for the resource type in its resource schema. You can only
-- specify one identifier. Primary identifiers can be specified as a string
-- or JSON; secondary identifiers must be specified as JSON.
--
-- For compound primary identifiers (that is, one that consists of multiple
-- resource properties strung together), to specify the primary identifier
-- as a string, list the property values /in the order they are specified/
-- in the primary identifier definition, separated by @|@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-identifier.html Identifying resources>
-- in the /Amazon Web Services Cloud Control API User Guide/.
updateResource_identifier :: Lens.Lens' UpdateResource Prelude.Text
updateResource_identifier :: Lens' UpdateResource Text
updateResource_identifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResource' {Text
identifier :: Text
$sel:identifier:UpdateResource' :: UpdateResource -> Text
identifier} -> Text
identifier) (\s :: UpdateResource
s@UpdateResource' {} Text
a -> UpdateResource
s {$sel:identifier:UpdateResource' :: Text
identifier = Text
a} :: UpdateResource)

-- | A JavaScript Object Notation (JSON) document listing the patch
-- operations that represent the updates to apply to the current resource
-- properties. For details, see
-- <https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations-update.html#resource-operations-update-patch Composing the patch document>
-- in the /Amazon Web Services Cloud Control API User Guide/.
updateResource_patchDocument :: Lens.Lens' UpdateResource Prelude.Text
updateResource_patchDocument :: Lens' UpdateResource Text
updateResource_patchDocument = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResource' {Sensitive Text
patchDocument :: Sensitive Text
$sel:patchDocument:UpdateResource' :: UpdateResource -> Sensitive Text
patchDocument} -> Sensitive Text
patchDocument) (\s :: UpdateResource
s@UpdateResource' {} Sensitive Text
a -> UpdateResource
s {$sel:patchDocument:UpdateResource' :: Sensitive Text
patchDocument = Sensitive Text
a} :: UpdateResource) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Core.AWSRequest UpdateResource where
  type
    AWSResponse UpdateResource =
      UpdateResourceResponse
  request :: (Service -> Service) -> UpdateResource -> Request UpdateResource
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateResource)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ProgressEvent -> Int -> UpdateResourceResponse
UpdateResourceResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ProgressEvent")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateResource where
  hashWithSalt :: Int -> UpdateResource -> Int
hashWithSalt Int
_salt UpdateResource' {Maybe Text
Text
Sensitive Text
patchDocument :: Sensitive Text
identifier :: Text
typeName :: Text
typeVersionId :: Maybe Text
roleArn :: Maybe Text
clientToken :: Maybe Text
$sel:patchDocument:UpdateResource' :: UpdateResource -> Sensitive Text
$sel:identifier:UpdateResource' :: UpdateResource -> Text
$sel:typeName:UpdateResource' :: UpdateResource -> Text
$sel:typeVersionId:UpdateResource' :: UpdateResource -> Maybe Text
$sel:roleArn:UpdateResource' :: UpdateResource -> Maybe Text
$sel:clientToken:UpdateResource' :: UpdateResource -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
typeVersionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
typeName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
identifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
patchDocument

instance Prelude.NFData UpdateResource where
  rnf :: UpdateResource -> ()
rnf UpdateResource' {Maybe Text
Text
Sensitive Text
patchDocument :: Sensitive Text
identifier :: Text
typeName :: Text
typeVersionId :: Maybe Text
roleArn :: Maybe Text
clientToken :: Maybe Text
$sel:patchDocument:UpdateResource' :: UpdateResource -> Sensitive Text
$sel:identifier:UpdateResource' :: UpdateResource -> Text
$sel:typeName:UpdateResource' :: UpdateResource -> Text
$sel:typeVersionId:UpdateResource' :: UpdateResource -> Maybe Text
$sel:roleArn:UpdateResource' :: UpdateResource -> Maybe Text
$sel:clientToken:UpdateResource' :: UpdateResource -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
typeVersionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
typeName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
identifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
patchDocument

instance Data.ToHeaders UpdateResource where
  toHeaders :: UpdateResource -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"CloudApiService.UpdateResource" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateResource where
  toJSON :: UpdateResource -> Value
toJSON UpdateResource' {Maybe Text
Text
Sensitive Text
patchDocument :: Sensitive Text
identifier :: Text
typeName :: Text
typeVersionId :: Maybe Text
roleArn :: Maybe Text
clientToken :: Maybe Text
$sel:patchDocument:UpdateResource' :: UpdateResource -> Sensitive Text
$sel:identifier:UpdateResource' :: UpdateResource -> Text
$sel:typeName:UpdateResource' :: UpdateResource -> Text
$sel:typeVersionId:UpdateResource' :: UpdateResource -> Maybe Text
$sel:roleArn:UpdateResource' :: UpdateResource -> Maybe Text
$sel:clientToken:UpdateResource' :: UpdateResource -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ClientToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
            (Key
"RoleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
roleArn,
            (Key
"TypeVersionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
typeVersionId,
            forall a. a -> Maybe a
Prelude.Just (Key
"TypeName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
typeName),
            forall a. a -> Maybe a
Prelude.Just (Key
"Identifier" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
identifier),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"PatchDocument" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
patchDocument)
          ]
      )

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

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

-- | /See:/ 'newUpdateResourceResponse' smart constructor.
data UpdateResourceResponse = UpdateResourceResponse'
  { -- | Represents the current status of the resource update request.
    --
    -- Use the @RequestToken@ of the @ProgressEvent@ with
    -- <https://docs.aws.amazon.com/cloudcontrolapi/latest/APIReference/API_GetResourceRequestStatus.html GetResourceRequestStatus>
    -- to return the current status of a resource operation request.
    UpdateResourceResponse -> Maybe ProgressEvent
progressEvent :: Prelude.Maybe ProgressEvent,
    -- | The response's http status code.
    UpdateResourceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateResourceResponse -> UpdateResourceResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateResourceResponse -> UpdateResourceResponse -> Bool
$c/= :: UpdateResourceResponse -> UpdateResourceResponse -> Bool
== :: UpdateResourceResponse -> UpdateResourceResponse -> Bool
$c== :: UpdateResourceResponse -> UpdateResourceResponse -> Bool
Prelude.Eq, Int -> UpdateResourceResponse -> ShowS
[UpdateResourceResponse] -> ShowS
UpdateResourceResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateResourceResponse] -> ShowS
$cshowList :: [UpdateResourceResponse] -> ShowS
show :: UpdateResourceResponse -> String
$cshow :: UpdateResourceResponse -> String
showsPrec :: Int -> UpdateResourceResponse -> ShowS
$cshowsPrec :: Int -> UpdateResourceResponse -> ShowS
Prelude.Show, forall x. Rep UpdateResourceResponse x -> UpdateResourceResponse
forall x. UpdateResourceResponse -> Rep UpdateResourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateResourceResponse x -> UpdateResourceResponse
$cfrom :: forall x. UpdateResourceResponse -> Rep UpdateResourceResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateResourceResponse' 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:
--
-- 'progressEvent', 'updateResourceResponse_progressEvent' - Represents the current status of the resource update request.
--
-- Use the @RequestToken@ of the @ProgressEvent@ with
-- <https://docs.aws.amazon.com/cloudcontrolapi/latest/APIReference/API_GetResourceRequestStatus.html GetResourceRequestStatus>
-- to return the current status of a resource operation request.
--
-- 'httpStatus', 'updateResourceResponse_httpStatus' - The response's http status code.
newUpdateResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateResourceResponse
newUpdateResourceResponse :: Int -> UpdateResourceResponse
newUpdateResourceResponse Int
pHttpStatus_ =
  UpdateResourceResponse'
    { $sel:progressEvent:UpdateResourceResponse' :: Maybe ProgressEvent
progressEvent =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Represents the current status of the resource update request.
--
-- Use the @RequestToken@ of the @ProgressEvent@ with
-- <https://docs.aws.amazon.com/cloudcontrolapi/latest/APIReference/API_GetResourceRequestStatus.html GetResourceRequestStatus>
-- to return the current status of a resource operation request.
updateResourceResponse_progressEvent :: Lens.Lens' UpdateResourceResponse (Prelude.Maybe ProgressEvent)
updateResourceResponse_progressEvent :: Lens' UpdateResourceResponse (Maybe ProgressEvent)
updateResourceResponse_progressEvent = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResourceResponse' {Maybe ProgressEvent
progressEvent :: Maybe ProgressEvent
$sel:progressEvent:UpdateResourceResponse' :: UpdateResourceResponse -> Maybe ProgressEvent
progressEvent} -> Maybe ProgressEvent
progressEvent) (\s :: UpdateResourceResponse
s@UpdateResourceResponse' {} Maybe ProgressEvent
a -> UpdateResourceResponse
s {$sel:progressEvent:UpdateResourceResponse' :: Maybe ProgressEvent
progressEvent = Maybe ProgressEvent
a} :: UpdateResourceResponse)

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

instance Prelude.NFData UpdateResourceResponse where
  rnf :: UpdateResourceResponse -> ()
rnf UpdateResourceResponse' {Int
Maybe ProgressEvent
httpStatus :: Int
progressEvent :: Maybe ProgressEvent
$sel:httpStatus:UpdateResourceResponse' :: UpdateResourceResponse -> Int
$sel:progressEvent:UpdateResourceResponse' :: UpdateResourceResponse -> Maybe ProgressEvent
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ProgressEvent
progressEvent
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus