{-# 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.CreateAddon
-- 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 Amazon EKS add-on.
--
-- Amazon EKS add-ons help to automate the provisioning and lifecycle
-- management of common operational software for Amazon EKS clusters.
-- Amazon EKS add-ons can only be used with Amazon EKS clusters running
-- version 1.18 with platform version @eks.3@ or later because add-ons rely
-- on the Server-side Apply Kubernetes feature, which is only available in
-- Kubernetes 1.18 and later.
module Amazonka.EKS.CreateAddon
  ( -- * Creating a Request
    CreateAddon (..),
    newCreateAddon,

    -- * Request Lenses
    createAddon_addonVersion,
    createAddon_serviceAccountRoleArn,
    createAddon_resolveConflicts,
    createAddon_clientRequestToken,
    createAddon_tags,
    createAddon_clusterName,
    createAddon_addonName,

    -- * Destructuring the Response
    CreateAddonResponse (..),
    newCreateAddonResponse,

    -- * Response Lenses
    createAddonResponse_addon,
    createAddonResponse_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:/ 'newCreateAddon' smart constructor.
data CreateAddon = CreateAddon'
  { -- | The version of the add-on. The version must match one of the versions
    -- returned by
    -- <https://docs.aws.amazon.com/eks/latest/APIReference/API_DescribeAddonVersions.html DescribeAddonVersions>
    -- .
    CreateAddon -> Maybe Text
addonVersion :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of an existing IAM role to bind to the
    -- add-on\'s service account. The role must be assigned the IAM permissions
    -- required by the add-on. If you don\'t specify an existing IAM role, then
    -- the add-on uses the permissions assigned to the node IAM role. For more
    -- information, see
    -- <https://docs.aws.amazon.com/eks/latest/userguide/create-node-role.html Amazon EKS node IAM role>
    -- in the /Amazon EKS User Guide/.
    --
    -- To specify an existing IAM role, you must have an IAM OpenID Connect
    -- (OIDC) provider created for your cluster. For more information, see
    -- <https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html Enabling IAM roles for service accounts on your cluster>
    -- in the /Amazon EKS User Guide/.
    CreateAddon -> Maybe Text
serviceAccountRoleArn :: Prelude.Maybe Prelude.Text,
    -- | How to resolve parameter value conflicts when migrating an existing
    -- add-on to an Amazon EKS add-on.
    CreateAddon -> Maybe ResolveConflicts
resolveConflicts :: Prelude.Maybe ResolveConflicts,
    -- | A unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request.
    CreateAddon -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | The metadata to apply to the cluster to assist with categorization and
    -- organization. Each tag consists of a key and an optional value, both of
    -- which you define.
    CreateAddon -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the cluster to create the add-on for.
    CreateAddon -> Text
clusterName :: Prelude.Text,
    -- | The name of the add-on. The name must match one of the names returned by
    -- <https://docs.aws.amazon.com/eks/latest/APIReference/API_DescribeAddonVersions.html DescribeAddonVersions>
    -- .
    CreateAddon -> Text
addonName :: Prelude.Text
  }
  deriving (CreateAddon -> CreateAddon -> Bool
(CreateAddon -> CreateAddon -> Bool)
-> (CreateAddon -> CreateAddon -> Bool) -> Eq CreateAddon
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAddon -> CreateAddon -> Bool
$c/= :: CreateAddon -> CreateAddon -> Bool
== :: CreateAddon -> CreateAddon -> Bool
$c== :: CreateAddon -> CreateAddon -> Bool
Prelude.Eq, ReadPrec [CreateAddon]
ReadPrec CreateAddon
Int -> ReadS CreateAddon
ReadS [CreateAddon]
(Int -> ReadS CreateAddon)
-> ReadS [CreateAddon]
-> ReadPrec CreateAddon
-> ReadPrec [CreateAddon]
-> Read CreateAddon
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAddon]
$creadListPrec :: ReadPrec [CreateAddon]
readPrec :: ReadPrec CreateAddon
$creadPrec :: ReadPrec CreateAddon
readList :: ReadS [CreateAddon]
$creadList :: ReadS [CreateAddon]
readsPrec :: Int -> ReadS CreateAddon
$creadsPrec :: Int -> ReadS CreateAddon
Prelude.Read, Int -> CreateAddon -> ShowS
[CreateAddon] -> ShowS
CreateAddon -> String
(Int -> CreateAddon -> ShowS)
-> (CreateAddon -> String)
-> ([CreateAddon] -> ShowS)
-> Show CreateAddon
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAddon] -> ShowS
$cshowList :: [CreateAddon] -> ShowS
show :: CreateAddon -> String
$cshow :: CreateAddon -> String
showsPrec :: Int -> CreateAddon -> ShowS
$cshowsPrec :: Int -> CreateAddon -> ShowS
Prelude.Show, (forall x. CreateAddon -> Rep CreateAddon x)
-> (forall x. Rep CreateAddon x -> CreateAddon)
-> Generic CreateAddon
forall x. Rep CreateAddon x -> CreateAddon
forall x. CreateAddon -> Rep CreateAddon x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAddon x -> CreateAddon
$cfrom :: forall x. CreateAddon -> Rep CreateAddon x
Prelude.Generic)

-- |
-- Create a value of 'CreateAddon' 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:
--
-- 'addonVersion', 'createAddon_addonVersion' - The version of the add-on. The version must match one of the versions
-- returned by
-- <https://docs.aws.amazon.com/eks/latest/APIReference/API_DescribeAddonVersions.html DescribeAddonVersions>
-- .
--
-- 'serviceAccountRoleArn', 'createAddon_serviceAccountRoleArn' - The Amazon Resource Name (ARN) of an existing IAM role to bind to the
-- add-on\'s service account. The role must be assigned the IAM permissions
-- required by the add-on. If you don\'t specify an existing IAM role, then
-- the add-on uses the permissions assigned to the node IAM role. For more
-- information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/create-node-role.html Amazon EKS node IAM role>
-- in the /Amazon EKS User Guide/.
--
-- To specify an existing IAM role, you must have an IAM OpenID Connect
-- (OIDC) provider created for your cluster. For more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html Enabling IAM roles for service accounts on your cluster>
-- in the /Amazon EKS User Guide/.
--
-- 'resolveConflicts', 'createAddon_resolveConflicts' - How to resolve parameter value conflicts when migrating an existing
-- add-on to an Amazon EKS add-on.
--
-- 'clientRequestToken', 'createAddon_clientRequestToken' - A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
--
-- 'tags', 'createAddon_tags' - The metadata to apply to the cluster to assist with categorization and
-- organization. Each tag consists of a key and an optional value, both of
-- which you define.
--
-- 'clusterName', 'createAddon_clusterName' - The name of the cluster to create the add-on for.
--
-- 'addonName', 'createAddon_addonName' - The name of the add-on. The name must match one of the names returned by
-- <https://docs.aws.amazon.com/eks/latest/APIReference/API_DescribeAddonVersions.html DescribeAddonVersions>
-- .
newCreateAddon ::
  -- | 'clusterName'
  Prelude.Text ->
  -- | 'addonName'
  Prelude.Text ->
  CreateAddon
newCreateAddon :: Text -> Text -> CreateAddon
newCreateAddon Text
pClusterName_ Text
pAddonName_ =
  CreateAddon' :: Maybe Text
-> Maybe Text
-> Maybe ResolveConflicts
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> CreateAddon
CreateAddon'
    { $sel:addonVersion:CreateAddon' :: Maybe Text
addonVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceAccountRoleArn:CreateAddon' :: Maybe Text
serviceAccountRoleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resolveConflicts:CreateAddon' :: Maybe ResolveConflicts
resolveConflicts = Maybe ResolveConflicts
forall a. Maybe a
Prelude.Nothing,
      $sel:clientRequestToken:CreateAddon' :: Maybe Text
clientRequestToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateAddon' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterName:CreateAddon' :: Text
clusterName = Text
pClusterName_,
      $sel:addonName:CreateAddon' :: Text
addonName = Text
pAddonName_
    }

-- | The version of the add-on. The version must match one of the versions
-- returned by
-- <https://docs.aws.amazon.com/eks/latest/APIReference/API_DescribeAddonVersions.html DescribeAddonVersions>
-- .
createAddon_addonVersion :: Lens.Lens' CreateAddon (Prelude.Maybe Prelude.Text)
createAddon_addonVersion :: (Maybe Text -> f (Maybe Text)) -> CreateAddon -> f CreateAddon
createAddon_addonVersion = (CreateAddon -> Maybe Text)
-> (CreateAddon -> Maybe Text -> CreateAddon)
-> Lens CreateAddon CreateAddon (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAddon' {Maybe Text
addonVersion :: Maybe Text
$sel:addonVersion:CreateAddon' :: CreateAddon -> Maybe Text
addonVersion} -> Maybe Text
addonVersion) (\s :: CreateAddon
s@CreateAddon' {} Maybe Text
a -> CreateAddon
s {$sel:addonVersion:CreateAddon' :: Maybe Text
addonVersion = Maybe Text
a} :: CreateAddon)

-- | The Amazon Resource Name (ARN) of an existing IAM role to bind to the
-- add-on\'s service account. The role must be assigned the IAM permissions
-- required by the add-on. If you don\'t specify an existing IAM role, then
-- the add-on uses the permissions assigned to the node IAM role. For more
-- information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/create-node-role.html Amazon EKS node IAM role>
-- in the /Amazon EKS User Guide/.
--
-- To specify an existing IAM role, you must have an IAM OpenID Connect
-- (OIDC) provider created for your cluster. For more information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html Enabling IAM roles for service accounts on your cluster>
-- in the /Amazon EKS User Guide/.
createAddon_serviceAccountRoleArn :: Lens.Lens' CreateAddon (Prelude.Maybe Prelude.Text)
createAddon_serviceAccountRoleArn :: (Maybe Text -> f (Maybe Text)) -> CreateAddon -> f CreateAddon
createAddon_serviceAccountRoleArn = (CreateAddon -> Maybe Text)
-> (CreateAddon -> Maybe Text -> CreateAddon)
-> Lens CreateAddon CreateAddon (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAddon' {Maybe Text
serviceAccountRoleArn :: Maybe Text
$sel:serviceAccountRoleArn:CreateAddon' :: CreateAddon -> Maybe Text
serviceAccountRoleArn} -> Maybe Text
serviceAccountRoleArn) (\s :: CreateAddon
s@CreateAddon' {} Maybe Text
a -> CreateAddon
s {$sel:serviceAccountRoleArn:CreateAddon' :: Maybe Text
serviceAccountRoleArn = Maybe Text
a} :: CreateAddon)

-- | How to resolve parameter value conflicts when migrating an existing
-- add-on to an Amazon EKS add-on.
createAddon_resolveConflicts :: Lens.Lens' CreateAddon (Prelude.Maybe ResolveConflicts)
createAddon_resolveConflicts :: (Maybe ResolveConflicts -> f (Maybe ResolveConflicts))
-> CreateAddon -> f CreateAddon
createAddon_resolveConflicts = (CreateAddon -> Maybe ResolveConflicts)
-> (CreateAddon -> Maybe ResolveConflicts -> CreateAddon)
-> Lens
     CreateAddon
     CreateAddon
     (Maybe ResolveConflicts)
     (Maybe ResolveConflicts)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAddon' {Maybe ResolveConflicts
resolveConflicts :: Maybe ResolveConflicts
$sel:resolveConflicts:CreateAddon' :: CreateAddon -> Maybe ResolveConflicts
resolveConflicts} -> Maybe ResolveConflicts
resolveConflicts) (\s :: CreateAddon
s@CreateAddon' {} Maybe ResolveConflicts
a -> CreateAddon
s {$sel:resolveConflicts:CreateAddon' :: Maybe ResolveConflicts
resolveConflicts = Maybe ResolveConflicts
a} :: CreateAddon)

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

-- | The metadata to apply to the cluster to assist with categorization and
-- organization. Each tag consists of a key and an optional value, both of
-- which you define.
createAddon_tags :: Lens.Lens' CreateAddon (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createAddon_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateAddon -> f CreateAddon
createAddon_tags = (CreateAddon -> Maybe (HashMap Text Text))
-> (CreateAddon -> Maybe (HashMap Text Text) -> CreateAddon)
-> Lens
     CreateAddon
     CreateAddon
     (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 (\CreateAddon' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateAddon' :: CreateAddon -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateAddon
s@CreateAddon' {} Maybe (HashMap Text Text)
a -> CreateAddon
s {$sel:tags:CreateAddon' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateAddon) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateAddon -> f CreateAddon)
-> ((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)))
-> CreateAddon
-> f CreateAddon
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 cluster to create the add-on for.
createAddon_clusterName :: Lens.Lens' CreateAddon Prelude.Text
createAddon_clusterName :: (Text -> f Text) -> CreateAddon -> f CreateAddon
createAddon_clusterName = (CreateAddon -> Text)
-> (CreateAddon -> Text -> CreateAddon)
-> Lens CreateAddon CreateAddon Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAddon' {Text
clusterName :: Text
$sel:clusterName:CreateAddon' :: CreateAddon -> Text
clusterName} -> Text
clusterName) (\s :: CreateAddon
s@CreateAddon' {} Text
a -> CreateAddon
s {$sel:clusterName:CreateAddon' :: Text
clusterName = Text
a} :: CreateAddon)

-- | The name of the add-on. The name must match one of the names returned by
-- <https://docs.aws.amazon.com/eks/latest/APIReference/API_DescribeAddonVersions.html DescribeAddonVersions>
-- .
createAddon_addonName :: Lens.Lens' CreateAddon Prelude.Text
createAddon_addonName :: (Text -> f Text) -> CreateAddon -> f CreateAddon
createAddon_addonName = (CreateAddon -> Text)
-> (CreateAddon -> Text -> CreateAddon)
-> Lens CreateAddon CreateAddon Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAddon' {Text
addonName :: Text
$sel:addonName:CreateAddon' :: CreateAddon -> Text
addonName} -> Text
addonName) (\s :: CreateAddon
s@CreateAddon' {} Text
a -> CreateAddon
s {$sel:addonName:CreateAddon' :: Text
addonName = Text
a} :: CreateAddon)

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

instance Prelude.NFData CreateAddon

instance Core.ToHeaders CreateAddon where
  toHeaders :: CreateAddon -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateAddon -> 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 CreateAddon where
  toJSON :: CreateAddon -> Value
toJSON CreateAddon' {Maybe Text
Maybe (HashMap Text Text)
Maybe ResolveConflicts
Text
addonName :: Text
clusterName :: Text
tags :: Maybe (HashMap Text Text)
clientRequestToken :: Maybe Text
resolveConflicts :: Maybe ResolveConflicts
serviceAccountRoleArn :: Maybe Text
addonVersion :: Maybe Text
$sel:addonName:CreateAddon' :: CreateAddon -> Text
$sel:clusterName:CreateAddon' :: CreateAddon -> Text
$sel:tags:CreateAddon' :: CreateAddon -> Maybe (HashMap Text Text)
$sel:clientRequestToken:CreateAddon' :: CreateAddon -> Maybe Text
$sel:resolveConflicts:CreateAddon' :: CreateAddon -> Maybe ResolveConflicts
$sel:serviceAccountRoleArn:CreateAddon' :: CreateAddon -> Maybe Text
$sel:addonVersion:CreateAddon' :: CreateAddon -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"addonVersion" 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
addonVersion,
            (Text
"serviceAccountRoleArn" 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
serviceAccountRoleArn,
            (Text
"resolveConflicts" Text -> ResolveConflicts -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ResolveConflicts -> Pair) -> Maybe ResolveConflicts -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResolveConflicts
resolveConflicts,
            (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
"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
"addonName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
addonName)
          ]
      )

instance Core.ToPath CreateAddon where
  toPath :: CreateAddon -> ByteString
toPath CreateAddon' {Maybe Text
Maybe (HashMap Text Text)
Maybe ResolveConflicts
Text
addonName :: Text
clusterName :: Text
tags :: Maybe (HashMap Text Text)
clientRequestToken :: Maybe Text
resolveConflicts :: Maybe ResolveConflicts
serviceAccountRoleArn :: Maybe Text
addonVersion :: Maybe Text
$sel:addonName:CreateAddon' :: CreateAddon -> Text
$sel:clusterName:CreateAddon' :: CreateAddon -> Text
$sel:tags:CreateAddon' :: CreateAddon -> Maybe (HashMap Text Text)
$sel:clientRequestToken:CreateAddon' :: CreateAddon -> Maybe Text
$sel:resolveConflicts:CreateAddon' :: CreateAddon -> Maybe ResolveConflicts
$sel:serviceAccountRoleArn:CreateAddon' :: CreateAddon -> Maybe Text
$sel:addonVersion:CreateAddon' :: CreateAddon -> 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
"/addons"]

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

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

-- |
-- Create a value of 'CreateAddonResponse' 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:
--
-- 'addon', 'createAddonResponse_addon' - Undocumented member.
--
-- 'httpStatus', 'createAddonResponse_httpStatus' - The response's http status code.
newCreateAddonResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateAddonResponse
newCreateAddonResponse :: Int -> CreateAddonResponse
newCreateAddonResponse Int
pHttpStatus_ =
  CreateAddonResponse' :: Maybe Addon -> Int -> CreateAddonResponse
CreateAddonResponse'
    { $sel:addon:CreateAddonResponse' :: Maybe Addon
addon = Maybe Addon
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateAddonResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
createAddonResponse_addon :: Lens.Lens' CreateAddonResponse (Prelude.Maybe Addon)
createAddonResponse_addon :: (Maybe Addon -> f (Maybe Addon))
-> CreateAddonResponse -> f CreateAddonResponse
createAddonResponse_addon = (CreateAddonResponse -> Maybe Addon)
-> (CreateAddonResponse -> Maybe Addon -> CreateAddonResponse)
-> Lens
     CreateAddonResponse CreateAddonResponse (Maybe Addon) (Maybe Addon)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAddonResponse' {Maybe Addon
addon :: Maybe Addon
$sel:addon:CreateAddonResponse' :: CreateAddonResponse -> Maybe Addon
addon} -> Maybe Addon
addon) (\s :: CreateAddonResponse
s@CreateAddonResponse' {} Maybe Addon
a -> CreateAddonResponse
s {$sel:addon:CreateAddonResponse' :: Maybe Addon
addon = Maybe Addon
a} :: CreateAddonResponse)

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

instance Prelude.NFData CreateAddonResponse