{-# 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.ServiceCatalog.CreateConstraint
-- 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)
--
-- Creates a constraint.
--
-- A delegated admin is authorized to invoke this command.
module Amazonka.ServiceCatalog.CreateConstraint
  ( -- * Creating a Request
    CreateConstraint (..),
    newCreateConstraint,

    -- * Request Lenses
    createConstraint_acceptLanguage,
    createConstraint_description,
    createConstraint_portfolioId,
    createConstraint_productId,
    createConstraint_parameters,
    createConstraint_type,
    createConstraint_idempotencyToken,

    -- * Destructuring the Response
    CreateConstraintResponse (..),
    newCreateConstraintResponse,

    -- * Response Lenses
    createConstraintResponse_status,
    createConstraintResponse_constraintDetail,
    createConstraintResponse_constraintParameters,
    createConstraintResponse_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.ServiceCatalog.Types

-- | /See:/ 'newCreateConstraint' smart constructor.
data CreateConstraint = CreateConstraint'
  { -- | The language code.
    --
    -- -   @en@ - English (default)
    --
    -- -   @jp@ - Japanese
    --
    -- -   @zh@ - Chinese
    CreateConstraint -> Maybe Text
acceptLanguage :: Prelude.Maybe Prelude.Text,
    -- | The description of the constraint.
    CreateConstraint -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The portfolio identifier.
    CreateConstraint -> Text
portfolioId :: Prelude.Text,
    -- | The product identifier.
    CreateConstraint -> Text
productId :: Prelude.Text,
    -- | The constraint parameters, in JSON format. The syntax depends on the
    -- constraint type as follows:
    --
    -- [LAUNCH]
    --     You are required to specify either the @RoleArn@ or the
    --     @LocalRoleName@ but can\'t use both.
    --
    --     Specify the @RoleArn@ property as follows:
    --
    --     @{\"RoleArn\" : \"arn:aws:iam::123456789012:role\/LaunchRole\"}@
    --
    --     Specify the @LocalRoleName@ property as follows:
    --
    --     @{\"LocalRoleName\": \"SCBasicLaunchRole\"}@
    --
    --     If you specify the @LocalRoleName@ property, when an account uses
    --     the launch constraint, the IAM role with that name in the account
    --     will be used. This allows launch-role constraints to be
    --     account-agnostic so the administrator can create fewer resources per
    --     shared account.
    --
    --     The given role name must exist in the account used to create the
    --     launch constraint and the account of the user who launches a product
    --     with this launch constraint.
    --
    --     You cannot have both a @LAUNCH@ and a @STACKSET@ constraint.
    --
    --     You also cannot have more than one @LAUNCH@ constraint on a product
    --     and portfolio.
    --
    -- [NOTIFICATION]
    --     Specify the @NotificationArns@ property as follows:
    --
    --     @{\"NotificationArns\" : [\"arn:aws:sns:us-east-1:123456789012:Topic\"]}@
    --
    -- [RESOURCE_UPDATE]
    --     Specify the @TagUpdatesOnProvisionedProduct@ property as follows:
    --
    --     @{\"Version\":\"2.0\",\"Properties\":{\"TagUpdateOnProvisionedProduct\":\"String\"}}@
    --
    --     The @TagUpdatesOnProvisionedProduct@ property accepts a string value
    --     of @ALLOWED@ or @NOT_ALLOWED@.
    --
    -- [STACKSET]
    --     Specify the @Parameters@ property as follows:
    --
    --     @{\"Version\": \"String\", \"Properties\": {\"AccountList\": [ \"String\" ], \"RegionList\": [ \"String\" ], \"AdminRole\": \"String\", \"ExecutionRole\": \"String\"}}@
    --
    --     You cannot have both a @LAUNCH@ and a @STACKSET@ constraint.
    --
    --     You also cannot have more than one @STACKSET@ constraint on a
    --     product and portfolio.
    --
    --     Products with a @STACKSET@ constraint will launch an AWS
    --     CloudFormation stack set.
    --
    -- [TEMPLATE]
    --     Specify the @Rules@ property. For more information, see
    --     <http://docs.aws.amazon.com/servicecatalog/latest/adminguide/reference-template_constraint_rules.html Template Constraint Rules>.
    CreateConstraint -> Text
parameters :: Prelude.Text,
    -- | The type of constraint.
    --
    -- -   @LAUNCH@
    --
    -- -   @NOTIFICATION@
    --
    -- -   @RESOURCE_UPDATE@
    --
    -- -   @STACKSET@
    --
    -- -   @TEMPLATE@
    CreateConstraint -> Text
type' :: Prelude.Text,
    -- | A unique identifier that you provide to ensure idempotency. If multiple
    -- requests differ only by the idempotency token, the same response is
    -- returned for each repeated request.
    CreateConstraint -> Text
idempotencyToken :: Prelude.Text
  }
  deriving (CreateConstraint -> CreateConstraint -> Bool
(CreateConstraint -> CreateConstraint -> Bool)
-> (CreateConstraint -> CreateConstraint -> Bool)
-> Eq CreateConstraint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateConstraint -> CreateConstraint -> Bool
$c/= :: CreateConstraint -> CreateConstraint -> Bool
== :: CreateConstraint -> CreateConstraint -> Bool
$c== :: CreateConstraint -> CreateConstraint -> Bool
Prelude.Eq, ReadPrec [CreateConstraint]
ReadPrec CreateConstraint
Int -> ReadS CreateConstraint
ReadS [CreateConstraint]
(Int -> ReadS CreateConstraint)
-> ReadS [CreateConstraint]
-> ReadPrec CreateConstraint
-> ReadPrec [CreateConstraint]
-> Read CreateConstraint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateConstraint]
$creadListPrec :: ReadPrec [CreateConstraint]
readPrec :: ReadPrec CreateConstraint
$creadPrec :: ReadPrec CreateConstraint
readList :: ReadS [CreateConstraint]
$creadList :: ReadS [CreateConstraint]
readsPrec :: Int -> ReadS CreateConstraint
$creadsPrec :: Int -> ReadS CreateConstraint
Prelude.Read, Int -> CreateConstraint -> ShowS
[CreateConstraint] -> ShowS
CreateConstraint -> String
(Int -> CreateConstraint -> ShowS)
-> (CreateConstraint -> String)
-> ([CreateConstraint] -> ShowS)
-> Show CreateConstraint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateConstraint] -> ShowS
$cshowList :: [CreateConstraint] -> ShowS
show :: CreateConstraint -> String
$cshow :: CreateConstraint -> String
showsPrec :: Int -> CreateConstraint -> ShowS
$cshowsPrec :: Int -> CreateConstraint -> ShowS
Prelude.Show, (forall x. CreateConstraint -> Rep CreateConstraint x)
-> (forall x. Rep CreateConstraint x -> CreateConstraint)
-> Generic CreateConstraint
forall x. Rep CreateConstraint x -> CreateConstraint
forall x. CreateConstraint -> Rep CreateConstraint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateConstraint x -> CreateConstraint
$cfrom :: forall x. CreateConstraint -> Rep CreateConstraint x
Prelude.Generic)

-- |
-- Create a value of 'CreateConstraint' 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:
--
-- 'acceptLanguage', 'createConstraint_acceptLanguage' - The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
--
-- 'description', 'createConstraint_description' - The description of the constraint.
--
-- 'portfolioId', 'createConstraint_portfolioId' - The portfolio identifier.
--
-- 'productId', 'createConstraint_productId' - The product identifier.
--
-- 'parameters', 'createConstraint_parameters' - The constraint parameters, in JSON format. The syntax depends on the
-- constraint type as follows:
--
-- [LAUNCH]
--     You are required to specify either the @RoleArn@ or the
--     @LocalRoleName@ but can\'t use both.
--
--     Specify the @RoleArn@ property as follows:
--
--     @{\"RoleArn\" : \"arn:aws:iam::123456789012:role\/LaunchRole\"}@
--
--     Specify the @LocalRoleName@ property as follows:
--
--     @{\"LocalRoleName\": \"SCBasicLaunchRole\"}@
--
--     If you specify the @LocalRoleName@ property, when an account uses
--     the launch constraint, the IAM role with that name in the account
--     will be used. This allows launch-role constraints to be
--     account-agnostic so the administrator can create fewer resources per
--     shared account.
--
--     The given role name must exist in the account used to create the
--     launch constraint and the account of the user who launches a product
--     with this launch constraint.
--
--     You cannot have both a @LAUNCH@ and a @STACKSET@ constraint.
--
--     You also cannot have more than one @LAUNCH@ constraint on a product
--     and portfolio.
--
-- [NOTIFICATION]
--     Specify the @NotificationArns@ property as follows:
--
--     @{\"NotificationArns\" : [\"arn:aws:sns:us-east-1:123456789012:Topic\"]}@
--
-- [RESOURCE_UPDATE]
--     Specify the @TagUpdatesOnProvisionedProduct@ property as follows:
--
--     @{\"Version\":\"2.0\",\"Properties\":{\"TagUpdateOnProvisionedProduct\":\"String\"}}@
--
--     The @TagUpdatesOnProvisionedProduct@ property accepts a string value
--     of @ALLOWED@ or @NOT_ALLOWED@.
--
-- [STACKSET]
--     Specify the @Parameters@ property as follows:
--
--     @{\"Version\": \"String\", \"Properties\": {\"AccountList\": [ \"String\" ], \"RegionList\": [ \"String\" ], \"AdminRole\": \"String\", \"ExecutionRole\": \"String\"}}@
--
--     You cannot have both a @LAUNCH@ and a @STACKSET@ constraint.
--
--     You also cannot have more than one @STACKSET@ constraint on a
--     product and portfolio.
--
--     Products with a @STACKSET@ constraint will launch an AWS
--     CloudFormation stack set.
--
-- [TEMPLATE]
--     Specify the @Rules@ property. For more information, see
--     <http://docs.aws.amazon.com/servicecatalog/latest/adminguide/reference-template_constraint_rules.html Template Constraint Rules>.
--
-- 'type'', 'createConstraint_type' - The type of constraint.
--
-- -   @LAUNCH@
--
-- -   @NOTIFICATION@
--
-- -   @RESOURCE_UPDATE@
--
-- -   @STACKSET@
--
-- -   @TEMPLATE@
--
-- 'idempotencyToken', 'createConstraint_idempotencyToken' - A unique identifier that you provide to ensure idempotency. If multiple
-- requests differ only by the idempotency token, the same response is
-- returned for each repeated request.
newCreateConstraint ::
  -- | 'portfolioId'
  Prelude.Text ->
  -- | 'productId'
  Prelude.Text ->
  -- | 'parameters'
  Prelude.Text ->
  -- | 'type''
  Prelude.Text ->
  -- | 'idempotencyToken'
  Prelude.Text ->
  CreateConstraint
newCreateConstraint :: Text -> Text -> Text -> Text -> Text -> CreateConstraint
newCreateConstraint
  Text
pPortfolioId_
  Text
pProductId_
  Text
pParameters_
  Text
pType_
  Text
pIdempotencyToken_ =
    CreateConstraint' :: Maybe Text
-> Maybe Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> CreateConstraint
CreateConstraint'
      { $sel:acceptLanguage:CreateConstraint' :: Maybe Text
acceptLanguage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:description:CreateConstraint' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:portfolioId:CreateConstraint' :: Text
portfolioId = Text
pPortfolioId_,
        $sel:productId:CreateConstraint' :: Text
productId = Text
pProductId_,
        $sel:parameters:CreateConstraint' :: Text
parameters = Text
pParameters_,
        $sel:type':CreateConstraint' :: Text
type' = Text
pType_,
        $sel:idempotencyToken:CreateConstraint' :: Text
idempotencyToken = Text
pIdempotencyToken_
      }

-- | The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
createConstraint_acceptLanguage :: Lens.Lens' CreateConstraint (Prelude.Maybe Prelude.Text)
createConstraint_acceptLanguage :: (Maybe Text -> f (Maybe Text))
-> CreateConstraint -> f CreateConstraint
createConstraint_acceptLanguage = (CreateConstraint -> Maybe Text)
-> (CreateConstraint -> Maybe Text -> CreateConstraint)
-> Lens CreateConstraint CreateConstraint (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConstraint' {Maybe Text
acceptLanguage :: Maybe Text
$sel:acceptLanguage:CreateConstraint' :: CreateConstraint -> Maybe Text
acceptLanguage} -> Maybe Text
acceptLanguage) (\s :: CreateConstraint
s@CreateConstraint' {} Maybe Text
a -> CreateConstraint
s {$sel:acceptLanguage:CreateConstraint' :: Maybe Text
acceptLanguage = Maybe Text
a} :: CreateConstraint)

-- | The description of the constraint.
createConstraint_description :: Lens.Lens' CreateConstraint (Prelude.Maybe Prelude.Text)
createConstraint_description :: (Maybe Text -> f (Maybe Text))
-> CreateConstraint -> f CreateConstraint
createConstraint_description = (CreateConstraint -> Maybe Text)
-> (CreateConstraint -> Maybe Text -> CreateConstraint)
-> Lens CreateConstraint CreateConstraint (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConstraint' {Maybe Text
description :: Maybe Text
$sel:description:CreateConstraint' :: CreateConstraint -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateConstraint
s@CreateConstraint' {} Maybe Text
a -> CreateConstraint
s {$sel:description:CreateConstraint' :: Maybe Text
description = Maybe Text
a} :: CreateConstraint)

-- | The portfolio identifier.
createConstraint_portfolioId :: Lens.Lens' CreateConstraint Prelude.Text
createConstraint_portfolioId :: (Text -> f Text) -> CreateConstraint -> f CreateConstraint
createConstraint_portfolioId = (CreateConstraint -> Text)
-> (CreateConstraint -> Text -> CreateConstraint)
-> Lens CreateConstraint CreateConstraint Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConstraint' {Text
portfolioId :: Text
$sel:portfolioId:CreateConstraint' :: CreateConstraint -> Text
portfolioId} -> Text
portfolioId) (\s :: CreateConstraint
s@CreateConstraint' {} Text
a -> CreateConstraint
s {$sel:portfolioId:CreateConstraint' :: Text
portfolioId = Text
a} :: CreateConstraint)

-- | The product identifier.
createConstraint_productId :: Lens.Lens' CreateConstraint Prelude.Text
createConstraint_productId :: (Text -> f Text) -> CreateConstraint -> f CreateConstraint
createConstraint_productId = (CreateConstraint -> Text)
-> (CreateConstraint -> Text -> CreateConstraint)
-> Lens CreateConstraint CreateConstraint Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConstraint' {Text
productId :: Text
$sel:productId:CreateConstraint' :: CreateConstraint -> Text
productId} -> Text
productId) (\s :: CreateConstraint
s@CreateConstraint' {} Text
a -> CreateConstraint
s {$sel:productId:CreateConstraint' :: Text
productId = Text
a} :: CreateConstraint)

-- | The constraint parameters, in JSON format. The syntax depends on the
-- constraint type as follows:
--
-- [LAUNCH]
--     You are required to specify either the @RoleArn@ or the
--     @LocalRoleName@ but can\'t use both.
--
--     Specify the @RoleArn@ property as follows:
--
--     @{\"RoleArn\" : \"arn:aws:iam::123456789012:role\/LaunchRole\"}@
--
--     Specify the @LocalRoleName@ property as follows:
--
--     @{\"LocalRoleName\": \"SCBasicLaunchRole\"}@
--
--     If you specify the @LocalRoleName@ property, when an account uses
--     the launch constraint, the IAM role with that name in the account
--     will be used. This allows launch-role constraints to be
--     account-agnostic so the administrator can create fewer resources per
--     shared account.
--
--     The given role name must exist in the account used to create the
--     launch constraint and the account of the user who launches a product
--     with this launch constraint.
--
--     You cannot have both a @LAUNCH@ and a @STACKSET@ constraint.
--
--     You also cannot have more than one @LAUNCH@ constraint on a product
--     and portfolio.
--
-- [NOTIFICATION]
--     Specify the @NotificationArns@ property as follows:
--
--     @{\"NotificationArns\" : [\"arn:aws:sns:us-east-1:123456789012:Topic\"]}@
--
-- [RESOURCE_UPDATE]
--     Specify the @TagUpdatesOnProvisionedProduct@ property as follows:
--
--     @{\"Version\":\"2.0\",\"Properties\":{\"TagUpdateOnProvisionedProduct\":\"String\"}}@
--
--     The @TagUpdatesOnProvisionedProduct@ property accepts a string value
--     of @ALLOWED@ or @NOT_ALLOWED@.
--
-- [STACKSET]
--     Specify the @Parameters@ property as follows:
--
--     @{\"Version\": \"String\", \"Properties\": {\"AccountList\": [ \"String\" ], \"RegionList\": [ \"String\" ], \"AdminRole\": \"String\", \"ExecutionRole\": \"String\"}}@
--
--     You cannot have both a @LAUNCH@ and a @STACKSET@ constraint.
--
--     You also cannot have more than one @STACKSET@ constraint on a
--     product and portfolio.
--
--     Products with a @STACKSET@ constraint will launch an AWS
--     CloudFormation stack set.
--
-- [TEMPLATE]
--     Specify the @Rules@ property. For more information, see
--     <http://docs.aws.amazon.com/servicecatalog/latest/adminguide/reference-template_constraint_rules.html Template Constraint Rules>.
createConstraint_parameters :: Lens.Lens' CreateConstraint Prelude.Text
createConstraint_parameters :: (Text -> f Text) -> CreateConstraint -> f CreateConstraint
createConstraint_parameters = (CreateConstraint -> Text)
-> (CreateConstraint -> Text -> CreateConstraint)
-> Lens CreateConstraint CreateConstraint Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConstraint' {Text
parameters :: Text
$sel:parameters:CreateConstraint' :: CreateConstraint -> Text
parameters} -> Text
parameters) (\s :: CreateConstraint
s@CreateConstraint' {} Text
a -> CreateConstraint
s {$sel:parameters:CreateConstraint' :: Text
parameters = Text
a} :: CreateConstraint)

-- | The type of constraint.
--
-- -   @LAUNCH@
--
-- -   @NOTIFICATION@
--
-- -   @RESOURCE_UPDATE@
--
-- -   @STACKSET@
--
-- -   @TEMPLATE@
createConstraint_type :: Lens.Lens' CreateConstraint Prelude.Text
createConstraint_type :: (Text -> f Text) -> CreateConstraint -> f CreateConstraint
createConstraint_type = (CreateConstraint -> Text)
-> (CreateConstraint -> Text -> CreateConstraint)
-> Lens CreateConstraint CreateConstraint Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConstraint' {Text
type' :: Text
$sel:type':CreateConstraint' :: CreateConstraint -> Text
type'} -> Text
type') (\s :: CreateConstraint
s@CreateConstraint' {} Text
a -> CreateConstraint
s {$sel:type':CreateConstraint' :: Text
type' = Text
a} :: CreateConstraint)

-- | A unique identifier that you provide to ensure idempotency. If multiple
-- requests differ only by the idempotency token, the same response is
-- returned for each repeated request.
createConstraint_idempotencyToken :: Lens.Lens' CreateConstraint Prelude.Text
createConstraint_idempotencyToken :: (Text -> f Text) -> CreateConstraint -> f CreateConstraint
createConstraint_idempotencyToken = (CreateConstraint -> Text)
-> (CreateConstraint -> Text -> CreateConstraint)
-> Lens CreateConstraint CreateConstraint Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConstraint' {Text
idempotencyToken :: Text
$sel:idempotencyToken:CreateConstraint' :: CreateConstraint -> Text
idempotencyToken} -> Text
idempotencyToken) (\s :: CreateConstraint
s@CreateConstraint' {} Text
a -> CreateConstraint
s {$sel:idempotencyToken:CreateConstraint' :: Text
idempotencyToken = Text
a} :: CreateConstraint)

instance Core.AWSRequest CreateConstraint where
  type
    AWSResponse CreateConstraint =
      CreateConstraintResponse
  request :: CreateConstraint -> Request CreateConstraint
request = Service -> CreateConstraint -> Request CreateConstraint
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateConstraint
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateConstraint)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateConstraint))
-> Logger
-> Service
-> Proxy CreateConstraint
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateConstraint)))
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 ->
          Maybe RequestStatus
-> Maybe ConstraintDetail
-> Maybe Text
-> Int
-> CreateConstraintResponse
CreateConstraintResponse'
            (Maybe RequestStatus
 -> Maybe ConstraintDetail
 -> Maybe Text
 -> Int
 -> CreateConstraintResponse)
-> Either String (Maybe RequestStatus)
-> Either
     String
     (Maybe ConstraintDetail
      -> Maybe Text -> Int -> CreateConstraintResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe RequestStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Status")
            Either
  String
  (Maybe ConstraintDetail
   -> Maybe Text -> Int -> CreateConstraintResponse)
-> Either String (Maybe ConstraintDetail)
-> Either String (Maybe Text -> Int -> CreateConstraintResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe ConstraintDetail)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ConstraintDetail")
            Either String (Maybe Text -> Int -> CreateConstraintResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateConstraintResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ConstraintParameters")
            Either String (Int -> CreateConstraintResponse)
-> Either String Int -> Either String CreateConstraintResponse
forall (f :: * -> *) a b. Applicative f => 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 CreateConstraint

instance Prelude.NFData CreateConstraint

instance Core.ToHeaders CreateConstraint where
  toHeaders :: CreateConstraint -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateConstraint -> 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
"AWS242ServiceCatalogService.CreateConstraint" ::
                          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 CreateConstraint where
  toJSON :: CreateConstraint -> Value
toJSON CreateConstraint' {Maybe Text
Text
idempotencyToken :: Text
type' :: Text
parameters :: Text
productId :: Text
portfolioId :: Text
description :: Maybe Text
acceptLanguage :: Maybe Text
$sel:idempotencyToken:CreateConstraint' :: CreateConstraint -> Text
$sel:type':CreateConstraint' :: CreateConstraint -> Text
$sel:parameters:CreateConstraint' :: CreateConstraint -> Text
$sel:productId:CreateConstraint' :: CreateConstraint -> Text
$sel:portfolioId:CreateConstraint' :: CreateConstraint -> Text
$sel:description:CreateConstraint' :: CreateConstraint -> Maybe Text
$sel:acceptLanguage:CreateConstraint' :: CreateConstraint -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AcceptLanguage" 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
acceptLanguage,
            (Text
"Description" 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
description,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PortfolioId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
portfolioId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ProductId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
productId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Parameters" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
parameters),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
type'),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"IdempotencyToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
idempotencyToken)
          ]
      )

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

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

-- | /See:/ 'newCreateConstraintResponse' smart constructor.
data CreateConstraintResponse = CreateConstraintResponse'
  { -- | The status of the current request.
    CreateConstraintResponse -> Maybe RequestStatus
status :: Prelude.Maybe RequestStatus,
    -- | Information about the constraint.
    CreateConstraintResponse -> Maybe ConstraintDetail
constraintDetail :: Prelude.Maybe ConstraintDetail,
    -- | The constraint parameters.
    CreateConstraintResponse -> Maybe Text
constraintParameters :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateConstraintResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateConstraintResponse -> CreateConstraintResponse -> Bool
(CreateConstraintResponse -> CreateConstraintResponse -> Bool)
-> (CreateConstraintResponse -> CreateConstraintResponse -> Bool)
-> Eq CreateConstraintResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateConstraintResponse -> CreateConstraintResponse -> Bool
$c/= :: CreateConstraintResponse -> CreateConstraintResponse -> Bool
== :: CreateConstraintResponse -> CreateConstraintResponse -> Bool
$c== :: CreateConstraintResponse -> CreateConstraintResponse -> Bool
Prelude.Eq, ReadPrec [CreateConstraintResponse]
ReadPrec CreateConstraintResponse
Int -> ReadS CreateConstraintResponse
ReadS [CreateConstraintResponse]
(Int -> ReadS CreateConstraintResponse)
-> ReadS [CreateConstraintResponse]
-> ReadPrec CreateConstraintResponse
-> ReadPrec [CreateConstraintResponse]
-> Read CreateConstraintResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateConstraintResponse]
$creadListPrec :: ReadPrec [CreateConstraintResponse]
readPrec :: ReadPrec CreateConstraintResponse
$creadPrec :: ReadPrec CreateConstraintResponse
readList :: ReadS [CreateConstraintResponse]
$creadList :: ReadS [CreateConstraintResponse]
readsPrec :: Int -> ReadS CreateConstraintResponse
$creadsPrec :: Int -> ReadS CreateConstraintResponse
Prelude.Read, Int -> CreateConstraintResponse -> ShowS
[CreateConstraintResponse] -> ShowS
CreateConstraintResponse -> String
(Int -> CreateConstraintResponse -> ShowS)
-> (CreateConstraintResponse -> String)
-> ([CreateConstraintResponse] -> ShowS)
-> Show CreateConstraintResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateConstraintResponse] -> ShowS
$cshowList :: [CreateConstraintResponse] -> ShowS
show :: CreateConstraintResponse -> String
$cshow :: CreateConstraintResponse -> String
showsPrec :: Int -> CreateConstraintResponse -> ShowS
$cshowsPrec :: Int -> CreateConstraintResponse -> ShowS
Prelude.Show, (forall x.
 CreateConstraintResponse -> Rep CreateConstraintResponse x)
-> (forall x.
    Rep CreateConstraintResponse x -> CreateConstraintResponse)
-> Generic CreateConstraintResponse
forall x.
Rep CreateConstraintResponse x -> CreateConstraintResponse
forall x.
CreateConstraintResponse -> Rep CreateConstraintResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateConstraintResponse x -> CreateConstraintResponse
$cfrom :: forall x.
CreateConstraintResponse -> Rep CreateConstraintResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateConstraintResponse' 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:
--
-- 'status', 'createConstraintResponse_status' - The status of the current request.
--
-- 'constraintDetail', 'createConstraintResponse_constraintDetail' - Information about the constraint.
--
-- 'constraintParameters', 'createConstraintResponse_constraintParameters' - The constraint parameters.
--
-- 'httpStatus', 'createConstraintResponse_httpStatus' - The response's http status code.
newCreateConstraintResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateConstraintResponse
newCreateConstraintResponse :: Int -> CreateConstraintResponse
newCreateConstraintResponse Int
pHttpStatus_ =
  CreateConstraintResponse' :: Maybe RequestStatus
-> Maybe ConstraintDetail
-> Maybe Text
-> Int
-> CreateConstraintResponse
CreateConstraintResponse'
    { $sel:status:CreateConstraintResponse' :: Maybe RequestStatus
status = Maybe RequestStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:constraintDetail:CreateConstraintResponse' :: Maybe ConstraintDetail
constraintDetail = Maybe ConstraintDetail
forall a. Maybe a
Prelude.Nothing,
      $sel:constraintParameters:CreateConstraintResponse' :: Maybe Text
constraintParameters = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateConstraintResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the current request.
createConstraintResponse_status :: Lens.Lens' CreateConstraintResponse (Prelude.Maybe RequestStatus)
createConstraintResponse_status :: (Maybe RequestStatus -> f (Maybe RequestStatus))
-> CreateConstraintResponse -> f CreateConstraintResponse
createConstraintResponse_status = (CreateConstraintResponse -> Maybe RequestStatus)
-> (CreateConstraintResponse
    -> Maybe RequestStatus -> CreateConstraintResponse)
-> Lens
     CreateConstraintResponse
     CreateConstraintResponse
     (Maybe RequestStatus)
     (Maybe RequestStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConstraintResponse' {Maybe RequestStatus
status :: Maybe RequestStatus
$sel:status:CreateConstraintResponse' :: CreateConstraintResponse -> Maybe RequestStatus
status} -> Maybe RequestStatus
status) (\s :: CreateConstraintResponse
s@CreateConstraintResponse' {} Maybe RequestStatus
a -> CreateConstraintResponse
s {$sel:status:CreateConstraintResponse' :: Maybe RequestStatus
status = Maybe RequestStatus
a} :: CreateConstraintResponse)

-- | Information about the constraint.
createConstraintResponse_constraintDetail :: Lens.Lens' CreateConstraintResponse (Prelude.Maybe ConstraintDetail)
createConstraintResponse_constraintDetail :: (Maybe ConstraintDetail -> f (Maybe ConstraintDetail))
-> CreateConstraintResponse -> f CreateConstraintResponse
createConstraintResponse_constraintDetail = (CreateConstraintResponse -> Maybe ConstraintDetail)
-> (CreateConstraintResponse
    -> Maybe ConstraintDetail -> CreateConstraintResponse)
-> Lens
     CreateConstraintResponse
     CreateConstraintResponse
     (Maybe ConstraintDetail)
     (Maybe ConstraintDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConstraintResponse' {Maybe ConstraintDetail
constraintDetail :: Maybe ConstraintDetail
$sel:constraintDetail:CreateConstraintResponse' :: CreateConstraintResponse -> Maybe ConstraintDetail
constraintDetail} -> Maybe ConstraintDetail
constraintDetail) (\s :: CreateConstraintResponse
s@CreateConstraintResponse' {} Maybe ConstraintDetail
a -> CreateConstraintResponse
s {$sel:constraintDetail:CreateConstraintResponse' :: Maybe ConstraintDetail
constraintDetail = Maybe ConstraintDetail
a} :: CreateConstraintResponse)

-- | The constraint parameters.
createConstraintResponse_constraintParameters :: Lens.Lens' CreateConstraintResponse (Prelude.Maybe Prelude.Text)
createConstraintResponse_constraintParameters :: (Maybe Text -> f (Maybe Text))
-> CreateConstraintResponse -> f CreateConstraintResponse
createConstraintResponse_constraintParameters = (CreateConstraintResponse -> Maybe Text)
-> (CreateConstraintResponse
    -> Maybe Text -> CreateConstraintResponse)
-> Lens
     CreateConstraintResponse
     CreateConstraintResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConstraintResponse' {Maybe Text
constraintParameters :: Maybe Text
$sel:constraintParameters:CreateConstraintResponse' :: CreateConstraintResponse -> Maybe Text
constraintParameters} -> Maybe Text
constraintParameters) (\s :: CreateConstraintResponse
s@CreateConstraintResponse' {} Maybe Text
a -> CreateConstraintResponse
s {$sel:constraintParameters:CreateConstraintResponse' :: Maybe Text
constraintParameters = Maybe Text
a} :: CreateConstraintResponse)

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

instance Prelude.NFData CreateConstraintResponse