amazonka-codebuild-2.0: gen/Amazonka/CodeBuild/GetResourcePolicy.hs
{-# 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.CodeBuild.GetResourcePolicy
-- Copyright : (c) 2013-2023 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets a resource policy that is identified by its resource ARN.
module Amazonka.CodeBuild.GetResourcePolicy
( -- * Creating a Request
GetResourcePolicy (..),
newGetResourcePolicy,
-- * Request Lenses
getResourcePolicy_resourceArn,
-- * Destructuring the Response
GetResourcePolicyResponse (..),
newGetResourcePolicyResponse,
-- * Response Lenses
getResourcePolicyResponse_policy,
getResourcePolicyResponse_httpStatus,
)
where
import Amazonka.CodeBuild.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:/ 'newGetResourcePolicy' smart constructor.
data GetResourcePolicy = GetResourcePolicy'
{ -- | The ARN of the resource that is associated with the resource policy.
resourceArn :: Prelude.Text
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'GetResourcePolicy' 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:
--
-- 'resourceArn', 'getResourcePolicy_resourceArn' - The ARN of the resource that is associated with the resource policy.
newGetResourcePolicy ::
-- | 'resourceArn'
Prelude.Text ->
GetResourcePolicy
newGetResourcePolicy pResourceArn_ =
GetResourcePolicy' {resourceArn = pResourceArn_}
-- | The ARN of the resource that is associated with the resource policy.
getResourcePolicy_resourceArn :: Lens.Lens' GetResourcePolicy Prelude.Text
getResourcePolicy_resourceArn = Lens.lens (\GetResourcePolicy' {resourceArn} -> resourceArn) (\s@GetResourcePolicy' {} a -> s {resourceArn = a} :: GetResourcePolicy)
instance Core.AWSRequest GetResourcePolicy where
type
AWSResponse GetResourcePolicy =
GetResourcePolicyResponse
request overrides =
Request.postJSON (overrides defaultService)
response =
Response.receiveJSON
( \s h x ->
GetResourcePolicyResponse'
Prelude.<$> (x Data..?> "policy")
Prelude.<*> (Prelude.pure (Prelude.fromEnum s))
)
instance Prelude.Hashable GetResourcePolicy where
hashWithSalt _salt GetResourcePolicy' {..} =
_salt `Prelude.hashWithSalt` resourceArn
instance Prelude.NFData GetResourcePolicy where
rnf GetResourcePolicy' {..} = Prelude.rnf resourceArn
instance Data.ToHeaders GetResourcePolicy where
toHeaders =
Prelude.const
( Prelude.mconcat
[ "X-Amz-Target"
Data.=# ( "CodeBuild_20161006.GetResourcePolicy" ::
Prelude.ByteString
),
"Content-Type"
Data.=# ( "application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON GetResourcePolicy where
toJSON GetResourcePolicy' {..} =
Data.object
( Prelude.catMaybes
[Prelude.Just ("resourceArn" Data..= resourceArn)]
)
instance Data.ToPath GetResourcePolicy where
toPath = Prelude.const "/"
instance Data.ToQuery GetResourcePolicy where
toQuery = Prelude.const Prelude.mempty
-- | /See:/ 'newGetResourcePolicyResponse' smart constructor.
data GetResourcePolicyResponse = GetResourcePolicyResponse'
{ -- | The resource policy for the resource identified by the input ARN
-- parameter.
policy :: Prelude.Maybe Prelude.Text,
-- | The response's http status code.
httpStatus :: Prelude.Int
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'GetResourcePolicyResponse' 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:
--
-- 'policy', 'getResourcePolicyResponse_policy' - The resource policy for the resource identified by the input ARN
-- parameter.
--
-- 'httpStatus', 'getResourcePolicyResponse_httpStatus' - The response's http status code.
newGetResourcePolicyResponse ::
-- | 'httpStatus'
Prelude.Int ->
GetResourcePolicyResponse
newGetResourcePolicyResponse pHttpStatus_ =
GetResourcePolicyResponse'
{ policy =
Prelude.Nothing,
httpStatus = pHttpStatus_
}
-- | The resource policy for the resource identified by the input ARN
-- parameter.
getResourcePolicyResponse_policy :: Lens.Lens' GetResourcePolicyResponse (Prelude.Maybe Prelude.Text)
getResourcePolicyResponse_policy = Lens.lens (\GetResourcePolicyResponse' {policy} -> policy) (\s@GetResourcePolicyResponse' {} a -> s {policy = a} :: GetResourcePolicyResponse)
-- | The response's http status code.
getResourcePolicyResponse_httpStatus :: Lens.Lens' GetResourcePolicyResponse Prelude.Int
getResourcePolicyResponse_httpStatus = Lens.lens (\GetResourcePolicyResponse' {httpStatus} -> httpStatus) (\s@GetResourcePolicyResponse' {} a -> s {httpStatus = a} :: GetResourcePolicyResponse)
instance Prelude.NFData GetResourcePolicyResponse where
rnf GetResourcePolicyResponse' {..} =
Prelude.rnf policy
`Prelude.seq` Prelude.rnf httpStatus