{-# 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.SageMaker.GetModelPackageGroupPolicy
-- 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)
--
-- Gets a resource policy that manages access for a model group. For
-- information about resource policies, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_identity-vs-resource.html Identity-based policies and resource-based policies>
-- in the /Amazon Web Services Identity and Access Management User Guide./.
module Amazonka.SageMaker.GetModelPackageGroupPolicy
  ( -- * Creating a Request
    GetModelPackageGroupPolicy (..),
    newGetModelPackageGroupPolicy,

    -- * Request Lenses
    getModelPackageGroupPolicy_modelPackageGroupName,

    -- * Destructuring the Response
    GetModelPackageGroupPolicyResponse (..),
    newGetModelPackageGroupPolicyResponse,

    -- * Response Lenses
    getModelPackageGroupPolicyResponse_httpStatus,
    getModelPackageGroupPolicyResponse_resourcePolicy,
  )
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.SageMaker.Types

-- | /See:/ 'newGetModelPackageGroupPolicy' smart constructor.
data GetModelPackageGroupPolicy = GetModelPackageGroupPolicy'
  { -- | The name of the model group for which to get the resource policy.
    GetModelPackageGroupPolicy -> Text
modelPackageGroupName :: Prelude.Text
  }
  deriving (GetModelPackageGroupPolicy -> GetModelPackageGroupPolicy -> Bool
(GetModelPackageGroupPolicy -> GetModelPackageGroupPolicy -> Bool)
-> (GetModelPackageGroupPolicy
    -> GetModelPackageGroupPolicy -> Bool)
-> Eq GetModelPackageGroupPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetModelPackageGroupPolicy -> GetModelPackageGroupPolicy -> Bool
$c/= :: GetModelPackageGroupPolicy -> GetModelPackageGroupPolicy -> Bool
== :: GetModelPackageGroupPolicy -> GetModelPackageGroupPolicy -> Bool
$c== :: GetModelPackageGroupPolicy -> GetModelPackageGroupPolicy -> Bool
Prelude.Eq, ReadPrec [GetModelPackageGroupPolicy]
ReadPrec GetModelPackageGroupPolicy
Int -> ReadS GetModelPackageGroupPolicy
ReadS [GetModelPackageGroupPolicy]
(Int -> ReadS GetModelPackageGroupPolicy)
-> ReadS [GetModelPackageGroupPolicy]
-> ReadPrec GetModelPackageGroupPolicy
-> ReadPrec [GetModelPackageGroupPolicy]
-> Read GetModelPackageGroupPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetModelPackageGroupPolicy]
$creadListPrec :: ReadPrec [GetModelPackageGroupPolicy]
readPrec :: ReadPrec GetModelPackageGroupPolicy
$creadPrec :: ReadPrec GetModelPackageGroupPolicy
readList :: ReadS [GetModelPackageGroupPolicy]
$creadList :: ReadS [GetModelPackageGroupPolicy]
readsPrec :: Int -> ReadS GetModelPackageGroupPolicy
$creadsPrec :: Int -> ReadS GetModelPackageGroupPolicy
Prelude.Read, Int -> GetModelPackageGroupPolicy -> ShowS
[GetModelPackageGroupPolicy] -> ShowS
GetModelPackageGroupPolicy -> String
(Int -> GetModelPackageGroupPolicy -> ShowS)
-> (GetModelPackageGroupPolicy -> String)
-> ([GetModelPackageGroupPolicy] -> ShowS)
-> Show GetModelPackageGroupPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetModelPackageGroupPolicy] -> ShowS
$cshowList :: [GetModelPackageGroupPolicy] -> ShowS
show :: GetModelPackageGroupPolicy -> String
$cshow :: GetModelPackageGroupPolicy -> String
showsPrec :: Int -> GetModelPackageGroupPolicy -> ShowS
$cshowsPrec :: Int -> GetModelPackageGroupPolicy -> ShowS
Prelude.Show, (forall x.
 GetModelPackageGroupPolicy -> Rep GetModelPackageGroupPolicy x)
-> (forall x.
    Rep GetModelPackageGroupPolicy x -> GetModelPackageGroupPolicy)
-> Generic GetModelPackageGroupPolicy
forall x.
Rep GetModelPackageGroupPolicy x -> GetModelPackageGroupPolicy
forall x.
GetModelPackageGroupPolicy -> Rep GetModelPackageGroupPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetModelPackageGroupPolicy x -> GetModelPackageGroupPolicy
$cfrom :: forall x.
GetModelPackageGroupPolicy -> Rep GetModelPackageGroupPolicy x
Prelude.Generic)

-- |
-- Create a value of 'GetModelPackageGroupPolicy' 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:
--
-- 'modelPackageGroupName', 'getModelPackageGroupPolicy_modelPackageGroupName' - The name of the model group for which to get the resource policy.
newGetModelPackageGroupPolicy ::
  -- | 'modelPackageGroupName'
  Prelude.Text ->
  GetModelPackageGroupPolicy
newGetModelPackageGroupPolicy :: Text -> GetModelPackageGroupPolicy
newGetModelPackageGroupPolicy Text
pModelPackageGroupName_ =
  GetModelPackageGroupPolicy' :: Text -> GetModelPackageGroupPolicy
GetModelPackageGroupPolicy'
    { $sel:modelPackageGroupName:GetModelPackageGroupPolicy' :: Text
modelPackageGroupName =
        Text
pModelPackageGroupName_
    }

-- | The name of the model group for which to get the resource policy.
getModelPackageGroupPolicy_modelPackageGroupName :: Lens.Lens' GetModelPackageGroupPolicy Prelude.Text
getModelPackageGroupPolicy_modelPackageGroupName :: (Text -> f Text)
-> GetModelPackageGroupPolicy -> f GetModelPackageGroupPolicy
getModelPackageGroupPolicy_modelPackageGroupName = (GetModelPackageGroupPolicy -> Text)
-> (GetModelPackageGroupPolicy
    -> Text -> GetModelPackageGroupPolicy)
-> Lens
     GetModelPackageGroupPolicy GetModelPackageGroupPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModelPackageGroupPolicy' {Text
modelPackageGroupName :: Text
$sel:modelPackageGroupName:GetModelPackageGroupPolicy' :: GetModelPackageGroupPolicy -> Text
modelPackageGroupName} -> Text
modelPackageGroupName) (\s :: GetModelPackageGroupPolicy
s@GetModelPackageGroupPolicy' {} Text
a -> GetModelPackageGroupPolicy
s {$sel:modelPackageGroupName:GetModelPackageGroupPolicy' :: Text
modelPackageGroupName = Text
a} :: GetModelPackageGroupPolicy)

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

instance Prelude.Hashable GetModelPackageGroupPolicy

instance Prelude.NFData GetModelPackageGroupPolicy

instance Core.ToHeaders GetModelPackageGroupPolicy where
  toHeaders :: GetModelPackageGroupPolicy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetModelPackageGroupPolicy -> 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
"SageMaker.GetModelPackageGroupPolicy" ::
                          Prelude.ByteString
                      ),
            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 GetModelPackageGroupPolicy where
  toJSON :: GetModelPackageGroupPolicy -> Value
toJSON GetModelPackageGroupPolicy' {Text
modelPackageGroupName :: Text
$sel:modelPackageGroupName:GetModelPackageGroupPolicy' :: GetModelPackageGroupPolicy -> Text
..} =
    [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
"ModelPackageGroupName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
modelPackageGroupName
              )
          ]
      )

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

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

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

-- |
-- Create a value of 'GetModelPackageGroupPolicyResponse' 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', 'getModelPackageGroupPolicyResponse_httpStatus' - The response's http status code.
--
-- 'resourcePolicy', 'getModelPackageGroupPolicyResponse_resourcePolicy' - The resource policy for the model group.
newGetModelPackageGroupPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'resourcePolicy'
  Prelude.Text ->
  GetModelPackageGroupPolicyResponse
newGetModelPackageGroupPolicyResponse :: Int -> Text -> GetModelPackageGroupPolicyResponse
newGetModelPackageGroupPolicyResponse
  Int
pHttpStatus_
  Text
pResourcePolicy_ =
    GetModelPackageGroupPolicyResponse' :: Int -> Text -> GetModelPackageGroupPolicyResponse
GetModelPackageGroupPolicyResponse'
      { $sel:httpStatus:GetModelPackageGroupPolicyResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:resourcePolicy:GetModelPackageGroupPolicyResponse' :: Text
resourcePolicy = Text
pResourcePolicy_
      }

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

-- | The resource policy for the model group.
getModelPackageGroupPolicyResponse_resourcePolicy :: Lens.Lens' GetModelPackageGroupPolicyResponse Prelude.Text
getModelPackageGroupPolicyResponse_resourcePolicy :: (Text -> f Text)
-> GetModelPackageGroupPolicyResponse
-> f GetModelPackageGroupPolicyResponse
getModelPackageGroupPolicyResponse_resourcePolicy = (GetModelPackageGroupPolicyResponse -> Text)
-> (GetModelPackageGroupPolicyResponse
    -> Text -> GetModelPackageGroupPolicyResponse)
-> Lens
     GetModelPackageGroupPolicyResponse
     GetModelPackageGroupPolicyResponse
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModelPackageGroupPolicyResponse' {Text
resourcePolicy :: Text
$sel:resourcePolicy:GetModelPackageGroupPolicyResponse' :: GetModelPackageGroupPolicyResponse -> Text
resourcePolicy} -> Text
resourcePolicy) (\s :: GetModelPackageGroupPolicyResponse
s@GetModelPackageGroupPolicyResponse' {} Text
a -> GetModelPackageGroupPolicyResponse
s {$sel:resourcePolicy:GetModelPackageGroupPolicyResponse' :: Text
resourcePolicy = Text
a} :: GetModelPackageGroupPolicyResponse)

instance
  Prelude.NFData
    GetModelPackageGroupPolicyResponse