{-# 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.EKS.CreateFargateProfile
-- 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 an Fargate profile for your Amazon EKS cluster. You must have at
-- least one Fargate profile in a cluster to be able to run pods on
-- Fargate.
--
-- The Fargate profile allows an administrator to declare which pods run on
-- Fargate and specify which pods run on which Fargate profile. This
-- declaration is done through the profile’s selectors. Each profile can
-- have up to five selectors that contain a namespace and labels. A
-- namespace is required for every selector. The label field consists of
-- multiple optional key-value pairs. Pods that match the selectors are
-- scheduled on Fargate. If a to-be-scheduled pod matches any of the
-- selectors in the Fargate profile, then that pod is run on Fargate.
--
-- When you create a Fargate profile, you must specify a pod execution role
-- to use with the pods that are scheduled with the profile. This role is
-- added to the cluster\'s Kubernetes
-- <https://kubernetes.io/docs/admin/authorization/rbac/ Role Based Access Control>
-- (RBAC) for authorization so that the @kubelet@ that is running on the
-- Fargate infrastructure can register with your Amazon EKS cluster so that
-- it can appear in your cluster as a node. The pod execution role also
-- provides IAM permissions to the Fargate infrastructure to allow read
-- access to Amazon ECR image repositories. For more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/pod-execution-role.html Pod Execution Role>
-- in the /Amazon EKS User Guide/.
--
-- Fargate profiles are immutable. However, you can create a new updated
-- profile to replace an existing profile and then delete the original
-- after the updated profile has finished creating.
--
-- If any Fargate profiles in a cluster are in the @DELETING@ status, you
-- must wait for that Fargate profile to finish deleting before you can
-- create any other profiles in that cluster.
--
-- For more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/fargate-profile.html Fargate Profile>
-- in the /Amazon EKS User Guide/.
module Amazonka.EKS.CreateFargateProfile
  ( -- * Creating a Request
    CreateFargateProfile (..),
    newCreateFargateProfile,

    -- * Request Lenses
    createFargateProfile_subnets,
    createFargateProfile_clientRequestToken,
    createFargateProfile_selectors,
    createFargateProfile_tags,
    createFargateProfile_fargateProfileName,
    createFargateProfile_clusterName,
    createFargateProfile_podExecutionRoleArn,

    -- * Destructuring the Response
    CreateFargateProfileResponse (..),
    newCreateFargateProfileResponse,

    -- * Response Lenses
    createFargateProfileResponse_fargateProfile,
    createFargateProfileResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateFargateProfile' smart constructor.
data CreateFargateProfile = CreateFargateProfile'
  { -- | The IDs of subnets to launch your pods into. At this time, pods running
    -- on Fargate are not assigned public IP addresses, so only private subnets
    -- (with no direct route to an Internet Gateway) are accepted for this
    -- parameter.
    CreateFargateProfile -> Maybe [Text]
subnets :: Prelude.Maybe [Prelude.Text],
    -- | Unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request.
    CreateFargateProfile -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | The selectors to match for pods to use this Fargate profile. Each
    -- selector must have an associated namespace. Optionally, you can also
    -- specify labels for a namespace. You may specify up to five selectors in
    -- a Fargate profile.
    CreateFargateProfile -> Maybe [FargateProfileSelector]
selectors :: Prelude.Maybe [FargateProfileSelector],
    -- | The metadata to apply to the Fargate profile to assist with
    -- categorization and organization. Each tag consists of a key and an
    -- optional value, both of which you define. Fargate profile tags do not
    -- propagate to any other resources associated with the Fargate profile,
    -- such as the pods that are scheduled with it.
    CreateFargateProfile -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the Fargate profile.
    CreateFargateProfile -> Text
fargateProfileName :: Prelude.Text,
    -- | The name of the Amazon EKS cluster to apply the Fargate profile to.
    CreateFargateProfile -> Text
clusterName :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the pod execution role to use for pods
    -- that match the selectors in the Fargate profile. The pod execution role
    -- allows Fargate infrastructure to register with your cluster as a node,
    -- and it provides read access to Amazon ECR image repositories. For more
    -- information, see
    -- <https://docs.aws.amazon.com/eks/latest/userguide/pod-execution-role.html Pod Execution Role>
    -- in the /Amazon EKS User Guide/.
    CreateFargateProfile -> Text
podExecutionRoleArn :: Prelude.Text
  }
  deriving (CreateFargateProfile -> CreateFargateProfile -> Bool
(CreateFargateProfile -> CreateFargateProfile -> Bool)
-> (CreateFargateProfile -> CreateFargateProfile -> Bool)
-> Eq CreateFargateProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFargateProfile -> CreateFargateProfile -> Bool
$c/= :: CreateFargateProfile -> CreateFargateProfile -> Bool
== :: CreateFargateProfile -> CreateFargateProfile -> Bool
$c== :: CreateFargateProfile -> CreateFargateProfile -> Bool
Prelude.Eq, ReadPrec [CreateFargateProfile]
ReadPrec CreateFargateProfile
Int -> ReadS CreateFargateProfile
ReadS [CreateFargateProfile]
(Int -> ReadS CreateFargateProfile)
-> ReadS [CreateFargateProfile]
-> ReadPrec CreateFargateProfile
-> ReadPrec [CreateFargateProfile]
-> Read CreateFargateProfile
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateFargateProfile]
$creadListPrec :: ReadPrec [CreateFargateProfile]
readPrec :: ReadPrec CreateFargateProfile
$creadPrec :: ReadPrec CreateFargateProfile
readList :: ReadS [CreateFargateProfile]
$creadList :: ReadS [CreateFargateProfile]
readsPrec :: Int -> ReadS CreateFargateProfile
$creadsPrec :: Int -> ReadS CreateFargateProfile
Prelude.Read, Int -> CreateFargateProfile -> ShowS
[CreateFargateProfile] -> ShowS
CreateFargateProfile -> String
(Int -> CreateFargateProfile -> ShowS)
-> (CreateFargateProfile -> String)
-> ([CreateFargateProfile] -> ShowS)
-> Show CreateFargateProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFargateProfile] -> ShowS
$cshowList :: [CreateFargateProfile] -> ShowS
show :: CreateFargateProfile -> String
$cshow :: CreateFargateProfile -> String
showsPrec :: Int -> CreateFargateProfile -> ShowS
$cshowsPrec :: Int -> CreateFargateProfile -> ShowS
Prelude.Show, (forall x. CreateFargateProfile -> Rep CreateFargateProfile x)
-> (forall x. Rep CreateFargateProfile x -> CreateFargateProfile)
-> Generic CreateFargateProfile
forall x. Rep CreateFargateProfile x -> CreateFargateProfile
forall x. CreateFargateProfile -> Rep CreateFargateProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateFargateProfile x -> CreateFargateProfile
$cfrom :: forall x. CreateFargateProfile -> Rep CreateFargateProfile x
Prelude.Generic)

-- |
-- Create a value of 'CreateFargateProfile' 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:
--
-- 'subnets', 'createFargateProfile_subnets' - The IDs of subnets to launch your pods into. At this time, pods running
-- on Fargate are not assigned public IP addresses, so only private subnets
-- (with no direct route to an Internet Gateway) are accepted for this
-- parameter.
--
-- 'clientRequestToken', 'createFargateProfile_clientRequestToken' - Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
--
-- 'selectors', 'createFargateProfile_selectors' - The selectors to match for pods to use this Fargate profile. Each
-- selector must have an associated namespace. Optionally, you can also
-- specify labels for a namespace. You may specify up to five selectors in
-- a Fargate profile.
--
-- 'tags', 'createFargateProfile_tags' - The metadata to apply to the Fargate profile to assist with
-- categorization and organization. Each tag consists of a key and an
-- optional value, both of which you define. Fargate profile tags do not
-- propagate to any other resources associated with the Fargate profile,
-- such as the pods that are scheduled with it.
--
-- 'fargateProfileName', 'createFargateProfile_fargateProfileName' - The name of the Fargate profile.
--
-- 'clusterName', 'createFargateProfile_clusterName' - The name of the Amazon EKS cluster to apply the Fargate profile to.
--
-- 'podExecutionRoleArn', 'createFargateProfile_podExecutionRoleArn' - The Amazon Resource Name (ARN) of the pod execution role to use for pods
-- that match the selectors in the Fargate profile. The pod execution role
-- allows Fargate infrastructure to register with your cluster as a node,
-- and it provides read access to Amazon ECR image repositories. For more
-- information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/pod-execution-role.html Pod Execution Role>
-- in the /Amazon EKS User Guide/.
newCreateFargateProfile ::
  -- | 'fargateProfileName'
  Prelude.Text ->
  -- | 'clusterName'
  Prelude.Text ->
  -- | 'podExecutionRoleArn'
  Prelude.Text ->
  CreateFargateProfile
newCreateFargateProfile :: Text -> Text -> Text -> CreateFargateProfile
newCreateFargateProfile
  Text
pFargateProfileName_
  Text
pClusterName_
  Text
pPodExecutionRoleArn_ =
    CreateFargateProfile' :: Maybe [Text]
-> Maybe Text
-> Maybe [FargateProfileSelector]
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> Text
-> CreateFargateProfile
CreateFargateProfile'
      { $sel:subnets:CreateFargateProfile' :: Maybe [Text]
subnets = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:clientRequestToken:CreateFargateProfile' :: Maybe Text
clientRequestToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:selectors:CreateFargateProfile' :: Maybe [FargateProfileSelector]
selectors = Maybe [FargateProfileSelector]
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateFargateProfile' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:fargateProfileName:CreateFargateProfile' :: Text
fargateProfileName = Text
pFargateProfileName_,
        $sel:clusterName:CreateFargateProfile' :: Text
clusterName = Text
pClusterName_,
        $sel:podExecutionRoleArn:CreateFargateProfile' :: Text
podExecutionRoleArn = Text
pPodExecutionRoleArn_
      }

-- | The IDs of subnets to launch your pods into. At this time, pods running
-- on Fargate are not assigned public IP addresses, so only private subnets
-- (with no direct route to an Internet Gateway) are accepted for this
-- parameter.
createFargateProfile_subnets :: Lens.Lens' CreateFargateProfile (Prelude.Maybe [Prelude.Text])
createFargateProfile_subnets :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateFargateProfile -> f CreateFargateProfile
createFargateProfile_subnets = (CreateFargateProfile -> Maybe [Text])
-> (CreateFargateProfile -> Maybe [Text] -> CreateFargateProfile)
-> Lens
     CreateFargateProfile
     CreateFargateProfile
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFargateProfile' {Maybe [Text]
subnets :: Maybe [Text]
$sel:subnets:CreateFargateProfile' :: CreateFargateProfile -> Maybe [Text]
subnets} -> Maybe [Text]
subnets) (\s :: CreateFargateProfile
s@CreateFargateProfile' {} Maybe [Text]
a -> CreateFargateProfile
s {$sel:subnets:CreateFargateProfile' :: Maybe [Text]
subnets = Maybe [Text]
a} :: CreateFargateProfile) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateFargateProfile -> f CreateFargateProfile)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateFargateProfile
-> f CreateFargateProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
createFargateProfile_clientRequestToken :: Lens.Lens' CreateFargateProfile (Prelude.Maybe Prelude.Text)
createFargateProfile_clientRequestToken :: (Maybe Text -> f (Maybe Text))
-> CreateFargateProfile -> f CreateFargateProfile
createFargateProfile_clientRequestToken = (CreateFargateProfile -> Maybe Text)
-> (CreateFargateProfile -> Maybe Text -> CreateFargateProfile)
-> Lens
     CreateFargateProfile CreateFargateProfile (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFargateProfile' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:CreateFargateProfile' :: CreateFargateProfile -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: CreateFargateProfile
s@CreateFargateProfile' {} Maybe Text
a -> CreateFargateProfile
s {$sel:clientRequestToken:CreateFargateProfile' :: Maybe Text
clientRequestToken = Maybe Text
a} :: CreateFargateProfile)

-- | The selectors to match for pods to use this Fargate profile. Each
-- selector must have an associated namespace. Optionally, you can also
-- specify labels for a namespace. You may specify up to five selectors in
-- a Fargate profile.
createFargateProfile_selectors :: Lens.Lens' CreateFargateProfile (Prelude.Maybe [FargateProfileSelector])
createFargateProfile_selectors :: (Maybe [FargateProfileSelector]
 -> f (Maybe [FargateProfileSelector]))
-> CreateFargateProfile -> f CreateFargateProfile
createFargateProfile_selectors = (CreateFargateProfile -> Maybe [FargateProfileSelector])
-> (CreateFargateProfile
    -> Maybe [FargateProfileSelector] -> CreateFargateProfile)
-> Lens
     CreateFargateProfile
     CreateFargateProfile
     (Maybe [FargateProfileSelector])
     (Maybe [FargateProfileSelector])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFargateProfile' {Maybe [FargateProfileSelector]
selectors :: Maybe [FargateProfileSelector]
$sel:selectors:CreateFargateProfile' :: CreateFargateProfile -> Maybe [FargateProfileSelector]
selectors} -> Maybe [FargateProfileSelector]
selectors) (\s :: CreateFargateProfile
s@CreateFargateProfile' {} Maybe [FargateProfileSelector]
a -> CreateFargateProfile
s {$sel:selectors:CreateFargateProfile' :: Maybe [FargateProfileSelector]
selectors = Maybe [FargateProfileSelector]
a} :: CreateFargateProfile) ((Maybe [FargateProfileSelector]
  -> f (Maybe [FargateProfileSelector]))
 -> CreateFargateProfile -> f CreateFargateProfile)
-> ((Maybe [FargateProfileSelector]
     -> f (Maybe [FargateProfileSelector]))
    -> Maybe [FargateProfileSelector]
    -> f (Maybe [FargateProfileSelector]))
-> (Maybe [FargateProfileSelector]
    -> f (Maybe [FargateProfileSelector]))
-> CreateFargateProfile
-> f CreateFargateProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [FargateProfileSelector]
  [FargateProfileSelector]
  [FargateProfileSelector]
  [FargateProfileSelector]
-> Iso
     (Maybe [FargateProfileSelector])
     (Maybe [FargateProfileSelector])
     (Maybe [FargateProfileSelector])
     (Maybe [FargateProfileSelector])
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
  [FargateProfileSelector]
  [FargateProfileSelector]
  [FargateProfileSelector]
  [FargateProfileSelector]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The metadata to apply to the Fargate profile to assist with
-- categorization and organization. Each tag consists of a key and an
-- optional value, both of which you define. Fargate profile tags do not
-- propagate to any other resources associated with the Fargate profile,
-- such as the pods that are scheduled with it.
createFargateProfile_tags :: Lens.Lens' CreateFargateProfile (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createFargateProfile_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateFargateProfile -> f CreateFargateProfile
createFargateProfile_tags = (CreateFargateProfile -> Maybe (HashMap Text Text))
-> (CreateFargateProfile
    -> Maybe (HashMap Text Text) -> CreateFargateProfile)
-> Lens
     CreateFargateProfile
     CreateFargateProfile
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFargateProfile' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateFargateProfile' :: CreateFargateProfile -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateFargateProfile
s@CreateFargateProfile' {} Maybe (HashMap Text Text)
a -> CreateFargateProfile
s {$sel:tags:CreateFargateProfile' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateFargateProfile) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateFargateProfile -> f CreateFargateProfile)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateFargateProfile
-> f CreateFargateProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the Fargate profile.
createFargateProfile_fargateProfileName :: Lens.Lens' CreateFargateProfile Prelude.Text
createFargateProfile_fargateProfileName :: (Text -> f Text) -> CreateFargateProfile -> f CreateFargateProfile
createFargateProfile_fargateProfileName = (CreateFargateProfile -> Text)
-> (CreateFargateProfile -> Text -> CreateFargateProfile)
-> Lens CreateFargateProfile CreateFargateProfile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFargateProfile' {Text
fargateProfileName :: Text
$sel:fargateProfileName:CreateFargateProfile' :: CreateFargateProfile -> Text
fargateProfileName} -> Text
fargateProfileName) (\s :: CreateFargateProfile
s@CreateFargateProfile' {} Text
a -> CreateFargateProfile
s {$sel:fargateProfileName:CreateFargateProfile' :: Text
fargateProfileName = Text
a} :: CreateFargateProfile)

-- | The name of the Amazon EKS cluster to apply the Fargate profile to.
createFargateProfile_clusterName :: Lens.Lens' CreateFargateProfile Prelude.Text
createFargateProfile_clusterName :: (Text -> f Text) -> CreateFargateProfile -> f CreateFargateProfile
createFargateProfile_clusterName = (CreateFargateProfile -> Text)
-> (CreateFargateProfile -> Text -> CreateFargateProfile)
-> Lens CreateFargateProfile CreateFargateProfile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFargateProfile' {Text
clusterName :: Text
$sel:clusterName:CreateFargateProfile' :: CreateFargateProfile -> Text
clusterName} -> Text
clusterName) (\s :: CreateFargateProfile
s@CreateFargateProfile' {} Text
a -> CreateFargateProfile
s {$sel:clusterName:CreateFargateProfile' :: Text
clusterName = Text
a} :: CreateFargateProfile)

-- | The Amazon Resource Name (ARN) of the pod execution role to use for pods
-- that match the selectors in the Fargate profile. The pod execution role
-- allows Fargate infrastructure to register with your cluster as a node,
-- and it provides read access to Amazon ECR image repositories. For more
-- information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/pod-execution-role.html Pod Execution Role>
-- in the /Amazon EKS User Guide/.
createFargateProfile_podExecutionRoleArn :: Lens.Lens' CreateFargateProfile Prelude.Text
createFargateProfile_podExecutionRoleArn :: (Text -> f Text) -> CreateFargateProfile -> f CreateFargateProfile
createFargateProfile_podExecutionRoleArn = (CreateFargateProfile -> Text)
-> (CreateFargateProfile -> Text -> CreateFargateProfile)
-> Lens CreateFargateProfile CreateFargateProfile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFargateProfile' {Text
podExecutionRoleArn :: Text
$sel:podExecutionRoleArn:CreateFargateProfile' :: CreateFargateProfile -> Text
podExecutionRoleArn} -> Text
podExecutionRoleArn) (\s :: CreateFargateProfile
s@CreateFargateProfile' {} Text
a -> CreateFargateProfile
s {$sel:podExecutionRoleArn:CreateFargateProfile' :: Text
podExecutionRoleArn = Text
a} :: CreateFargateProfile)

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

instance Prelude.NFData CreateFargateProfile

instance Core.ToHeaders CreateFargateProfile where
  toHeaders :: CreateFargateProfile -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateFargateProfile -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 CreateFargateProfile where
  toJSON :: CreateFargateProfile -> Value
toJSON CreateFargateProfile' {Maybe [Text]
Maybe [FargateProfileSelector]
Maybe Text
Maybe (HashMap Text Text)
Text
podExecutionRoleArn :: Text
clusterName :: Text
fargateProfileName :: Text
tags :: Maybe (HashMap Text Text)
selectors :: Maybe [FargateProfileSelector]
clientRequestToken :: Maybe Text
subnets :: Maybe [Text]
$sel:podExecutionRoleArn:CreateFargateProfile' :: CreateFargateProfile -> Text
$sel:clusterName:CreateFargateProfile' :: CreateFargateProfile -> Text
$sel:fargateProfileName:CreateFargateProfile' :: CreateFargateProfile -> Text
$sel:tags:CreateFargateProfile' :: CreateFargateProfile -> Maybe (HashMap Text Text)
$sel:selectors:CreateFargateProfile' :: CreateFargateProfile -> Maybe [FargateProfileSelector]
$sel:clientRequestToken:CreateFargateProfile' :: CreateFargateProfile -> Maybe Text
$sel:subnets:CreateFargateProfile' :: CreateFargateProfile -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"subnets" 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]
subnets,
            (Text
"clientRequestToken" 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
clientRequestToken,
            (Text
"selectors" Text -> [FargateProfileSelector] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([FargateProfileSelector] -> Pair)
-> Maybe [FargateProfileSelector] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [FargateProfileSelector]
selectors,
            (Text
"tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"fargateProfileName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fargateProfileName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"podExecutionRoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
podExecutionRoleArn)
          ]
      )

instance Core.ToPath CreateFargateProfile where
  toPath :: CreateFargateProfile -> ByteString
toPath CreateFargateProfile' {Maybe [Text]
Maybe [FargateProfileSelector]
Maybe Text
Maybe (HashMap Text Text)
Text
podExecutionRoleArn :: Text
clusterName :: Text
fargateProfileName :: Text
tags :: Maybe (HashMap Text Text)
selectors :: Maybe [FargateProfileSelector]
clientRequestToken :: Maybe Text
subnets :: Maybe [Text]
$sel:podExecutionRoleArn:CreateFargateProfile' :: CreateFargateProfile -> Text
$sel:clusterName:CreateFargateProfile' :: CreateFargateProfile -> Text
$sel:fargateProfileName:CreateFargateProfile' :: CreateFargateProfile -> Text
$sel:tags:CreateFargateProfile' :: CreateFargateProfile -> Maybe (HashMap Text Text)
$sel:selectors:CreateFargateProfile' :: CreateFargateProfile -> Maybe [FargateProfileSelector]
$sel:clientRequestToken:CreateFargateProfile' :: CreateFargateProfile -> Maybe Text
$sel:subnets:CreateFargateProfile' :: CreateFargateProfile -> Maybe [Text]
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/clusters/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
clusterName,
        ByteString
"/fargate-profiles"
      ]

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

-- | /See:/ 'newCreateFargateProfileResponse' smart constructor.
data CreateFargateProfileResponse = CreateFargateProfileResponse'
  { -- | The full description of your new Fargate profile.
    CreateFargateProfileResponse -> Maybe FargateProfile
fargateProfile :: Prelude.Maybe FargateProfile,
    -- | The response's http status code.
    CreateFargateProfileResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateFargateProfileResponse
-> CreateFargateProfileResponse -> Bool
(CreateFargateProfileResponse
 -> CreateFargateProfileResponse -> Bool)
-> (CreateFargateProfileResponse
    -> CreateFargateProfileResponse -> Bool)
-> Eq CreateFargateProfileResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFargateProfileResponse
-> CreateFargateProfileResponse -> Bool
$c/= :: CreateFargateProfileResponse
-> CreateFargateProfileResponse -> Bool
== :: CreateFargateProfileResponse
-> CreateFargateProfileResponse -> Bool
$c== :: CreateFargateProfileResponse
-> CreateFargateProfileResponse -> Bool
Prelude.Eq, ReadPrec [CreateFargateProfileResponse]
ReadPrec CreateFargateProfileResponse
Int -> ReadS CreateFargateProfileResponse
ReadS [CreateFargateProfileResponse]
(Int -> ReadS CreateFargateProfileResponse)
-> ReadS [CreateFargateProfileResponse]
-> ReadPrec CreateFargateProfileResponse
-> ReadPrec [CreateFargateProfileResponse]
-> Read CreateFargateProfileResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateFargateProfileResponse]
$creadListPrec :: ReadPrec [CreateFargateProfileResponse]
readPrec :: ReadPrec CreateFargateProfileResponse
$creadPrec :: ReadPrec CreateFargateProfileResponse
readList :: ReadS [CreateFargateProfileResponse]
$creadList :: ReadS [CreateFargateProfileResponse]
readsPrec :: Int -> ReadS CreateFargateProfileResponse
$creadsPrec :: Int -> ReadS CreateFargateProfileResponse
Prelude.Read, Int -> CreateFargateProfileResponse -> ShowS
[CreateFargateProfileResponse] -> ShowS
CreateFargateProfileResponse -> String
(Int -> CreateFargateProfileResponse -> ShowS)
-> (CreateFargateProfileResponse -> String)
-> ([CreateFargateProfileResponse] -> ShowS)
-> Show CreateFargateProfileResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFargateProfileResponse] -> ShowS
$cshowList :: [CreateFargateProfileResponse] -> ShowS
show :: CreateFargateProfileResponse -> String
$cshow :: CreateFargateProfileResponse -> String
showsPrec :: Int -> CreateFargateProfileResponse -> ShowS
$cshowsPrec :: Int -> CreateFargateProfileResponse -> ShowS
Prelude.Show, (forall x.
 CreateFargateProfileResponse -> Rep CreateFargateProfileResponse x)
-> (forall x.
    Rep CreateFargateProfileResponse x -> CreateFargateProfileResponse)
-> Generic CreateFargateProfileResponse
forall x.
Rep CreateFargateProfileResponse x -> CreateFargateProfileResponse
forall x.
CreateFargateProfileResponse -> Rep CreateFargateProfileResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateFargateProfileResponse x -> CreateFargateProfileResponse
$cfrom :: forall x.
CreateFargateProfileResponse -> Rep CreateFargateProfileResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateFargateProfileResponse' 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:
--
-- 'fargateProfile', 'createFargateProfileResponse_fargateProfile' - The full description of your new Fargate profile.
--
-- 'httpStatus', 'createFargateProfileResponse_httpStatus' - The response's http status code.
newCreateFargateProfileResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateFargateProfileResponse
newCreateFargateProfileResponse :: Int -> CreateFargateProfileResponse
newCreateFargateProfileResponse Int
pHttpStatus_ =
  CreateFargateProfileResponse' :: Maybe FargateProfile -> Int -> CreateFargateProfileResponse
CreateFargateProfileResponse'
    { $sel:fargateProfile:CreateFargateProfileResponse' :: Maybe FargateProfile
fargateProfile =
        Maybe FargateProfile
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateFargateProfileResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The full description of your new Fargate profile.
createFargateProfileResponse_fargateProfile :: Lens.Lens' CreateFargateProfileResponse (Prelude.Maybe FargateProfile)
createFargateProfileResponse_fargateProfile :: (Maybe FargateProfile -> f (Maybe FargateProfile))
-> CreateFargateProfileResponse -> f CreateFargateProfileResponse
createFargateProfileResponse_fargateProfile = (CreateFargateProfileResponse -> Maybe FargateProfile)
-> (CreateFargateProfileResponse
    -> Maybe FargateProfile -> CreateFargateProfileResponse)
-> Lens
     CreateFargateProfileResponse
     CreateFargateProfileResponse
     (Maybe FargateProfile)
     (Maybe FargateProfile)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFargateProfileResponse' {Maybe FargateProfile
fargateProfile :: Maybe FargateProfile
$sel:fargateProfile:CreateFargateProfileResponse' :: CreateFargateProfileResponse -> Maybe FargateProfile
fargateProfile} -> Maybe FargateProfile
fargateProfile) (\s :: CreateFargateProfileResponse
s@CreateFargateProfileResponse' {} Maybe FargateProfile
a -> CreateFargateProfileResponse
s {$sel:fargateProfile:CreateFargateProfileResponse' :: Maybe FargateProfile
fargateProfile = Maybe FargateProfile
a} :: CreateFargateProfileResponse)

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

instance Prelude.NFData CreateFargateProfileResponse