{-# 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.ECS.DeleteAccountSetting
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disables an account setting for a specified IAM user, IAM role, or the
-- root user for an account.
module Amazonka.ECS.DeleteAccountSetting
  ( -- * Creating a Request
    DeleteAccountSetting (..),
    newDeleteAccountSetting,

    -- * Request Lenses
    deleteAccountSetting_principalArn,
    deleteAccountSetting_name,

    -- * Destructuring the Response
    DeleteAccountSettingResponse (..),
    newDeleteAccountSettingResponse,

    -- * Response Lenses
    deleteAccountSettingResponse_setting,
    deleteAccountSettingResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ECS.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteAccountSetting' smart constructor.
data DeleteAccountSetting = DeleteAccountSetting'
  { -- | The Amazon Resource Name (ARN) of the principal. It can be an IAM user,
    -- IAM role, or the root user. If you specify the root user, it disables
    -- the account setting for all IAM users, IAM roles, and the root user of
    -- the account unless an IAM user or role explicitly overrides these
    -- settings. If this field is omitted, the setting is changed only for the
    -- authenticated user.
    DeleteAccountSetting -> Maybe Text
principalArn :: Prelude.Maybe Prelude.Text,
    -- | The resource name to disable the account setting for. If
    -- @serviceLongArnFormat@ is specified, the ARN for your Amazon ECS
    -- services is affected. If @taskLongArnFormat@ is specified, the ARN and
    -- resource ID for your Amazon ECS tasks is affected. If
    -- @containerInstanceLongArnFormat@ is specified, the ARN and resource ID
    -- for your Amazon ECS container instances is affected. If @awsvpcTrunking@
    -- is specified, the ENI limit for your Amazon ECS container instances is
    -- affected.
    DeleteAccountSetting -> SettingName
name :: SettingName
  }
  deriving (DeleteAccountSetting -> DeleteAccountSetting -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteAccountSetting -> DeleteAccountSetting -> Bool
$c/= :: DeleteAccountSetting -> DeleteAccountSetting -> Bool
== :: DeleteAccountSetting -> DeleteAccountSetting -> Bool
$c== :: DeleteAccountSetting -> DeleteAccountSetting -> Bool
Prelude.Eq, ReadPrec [DeleteAccountSetting]
ReadPrec DeleteAccountSetting
Int -> ReadS DeleteAccountSetting
ReadS [DeleteAccountSetting]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteAccountSetting]
$creadListPrec :: ReadPrec [DeleteAccountSetting]
readPrec :: ReadPrec DeleteAccountSetting
$creadPrec :: ReadPrec DeleteAccountSetting
readList :: ReadS [DeleteAccountSetting]
$creadList :: ReadS [DeleteAccountSetting]
readsPrec :: Int -> ReadS DeleteAccountSetting
$creadsPrec :: Int -> ReadS DeleteAccountSetting
Prelude.Read, Int -> DeleteAccountSetting -> ShowS
[DeleteAccountSetting] -> ShowS
DeleteAccountSetting -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteAccountSetting] -> ShowS
$cshowList :: [DeleteAccountSetting] -> ShowS
show :: DeleteAccountSetting -> String
$cshow :: DeleteAccountSetting -> String
showsPrec :: Int -> DeleteAccountSetting -> ShowS
$cshowsPrec :: Int -> DeleteAccountSetting -> ShowS
Prelude.Show, forall x. Rep DeleteAccountSetting x -> DeleteAccountSetting
forall x. DeleteAccountSetting -> Rep DeleteAccountSetting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteAccountSetting x -> DeleteAccountSetting
$cfrom :: forall x. DeleteAccountSetting -> Rep DeleteAccountSetting x
Prelude.Generic)

-- |
-- Create a value of 'DeleteAccountSetting' 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:
--
-- 'principalArn', 'deleteAccountSetting_principalArn' - The Amazon Resource Name (ARN) of the principal. It can be an IAM user,
-- IAM role, or the root user. If you specify the root user, it disables
-- the account setting for all IAM users, IAM roles, and the root user of
-- the account unless an IAM user or role explicitly overrides these
-- settings. If this field is omitted, the setting is changed only for the
-- authenticated user.
--
-- 'name', 'deleteAccountSetting_name' - The resource name to disable the account setting for. If
-- @serviceLongArnFormat@ is specified, the ARN for your Amazon ECS
-- services is affected. If @taskLongArnFormat@ is specified, the ARN and
-- resource ID for your Amazon ECS tasks is affected. If
-- @containerInstanceLongArnFormat@ is specified, the ARN and resource ID
-- for your Amazon ECS container instances is affected. If @awsvpcTrunking@
-- is specified, the ENI limit for your Amazon ECS container instances is
-- affected.
newDeleteAccountSetting ::
  -- | 'name'
  SettingName ->
  DeleteAccountSetting
newDeleteAccountSetting :: SettingName -> DeleteAccountSetting
newDeleteAccountSetting SettingName
pName_ =
  DeleteAccountSetting'
    { $sel:principalArn:DeleteAccountSetting' :: Maybe Text
principalArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:name:DeleteAccountSetting' :: SettingName
name = SettingName
pName_
    }

-- | The Amazon Resource Name (ARN) of the principal. It can be an IAM user,
-- IAM role, or the root user. If you specify the root user, it disables
-- the account setting for all IAM users, IAM roles, and the root user of
-- the account unless an IAM user or role explicitly overrides these
-- settings. If this field is omitted, the setting is changed only for the
-- authenticated user.
deleteAccountSetting_principalArn :: Lens.Lens' DeleteAccountSetting (Prelude.Maybe Prelude.Text)
deleteAccountSetting_principalArn :: Lens' DeleteAccountSetting (Maybe Text)
deleteAccountSetting_principalArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAccountSetting' {Maybe Text
principalArn :: Maybe Text
$sel:principalArn:DeleteAccountSetting' :: DeleteAccountSetting -> Maybe Text
principalArn} -> Maybe Text
principalArn) (\s :: DeleteAccountSetting
s@DeleteAccountSetting' {} Maybe Text
a -> DeleteAccountSetting
s {$sel:principalArn:DeleteAccountSetting' :: Maybe Text
principalArn = Maybe Text
a} :: DeleteAccountSetting)

-- | The resource name to disable the account setting for. If
-- @serviceLongArnFormat@ is specified, the ARN for your Amazon ECS
-- services is affected. If @taskLongArnFormat@ is specified, the ARN and
-- resource ID for your Amazon ECS tasks is affected. If
-- @containerInstanceLongArnFormat@ is specified, the ARN and resource ID
-- for your Amazon ECS container instances is affected. If @awsvpcTrunking@
-- is specified, the ENI limit for your Amazon ECS container instances is
-- affected.
deleteAccountSetting_name :: Lens.Lens' DeleteAccountSetting SettingName
deleteAccountSetting_name :: Lens' DeleteAccountSetting SettingName
deleteAccountSetting_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAccountSetting' {SettingName
name :: SettingName
$sel:name:DeleteAccountSetting' :: DeleteAccountSetting -> SettingName
name} -> SettingName
name) (\s :: DeleteAccountSetting
s@DeleteAccountSetting' {} SettingName
a -> DeleteAccountSetting
s {$sel:name:DeleteAccountSetting' :: SettingName
name = SettingName
a} :: DeleteAccountSetting)

instance Core.AWSRequest DeleteAccountSetting where
  type
    AWSResponse DeleteAccountSetting =
      DeleteAccountSettingResponse
  request :: (Service -> Service)
-> DeleteAccountSetting -> Request DeleteAccountSetting
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteAccountSetting
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteAccountSetting)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Setting -> Int -> DeleteAccountSettingResponse
DeleteAccountSettingResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"setting")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteAccountSetting where
  hashWithSalt :: Int -> DeleteAccountSetting -> Int
hashWithSalt Int
_salt DeleteAccountSetting' {Maybe Text
SettingName
name :: SettingName
principalArn :: Maybe Text
$sel:name:DeleteAccountSetting' :: DeleteAccountSetting -> SettingName
$sel:principalArn:DeleteAccountSetting' :: DeleteAccountSetting -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
principalArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SettingName
name

instance Prelude.NFData DeleteAccountSetting where
  rnf :: DeleteAccountSetting -> ()
rnf DeleteAccountSetting' {Maybe Text
SettingName
name :: SettingName
principalArn :: Maybe Text
$sel:name:DeleteAccountSetting' :: DeleteAccountSetting -> SettingName
$sel:principalArn:DeleteAccountSetting' :: DeleteAccountSetting -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
principalArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SettingName
name

instance Data.ToHeaders DeleteAccountSetting where
  toHeaders :: DeleteAccountSetting -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AmazonEC2ContainerServiceV20141113.DeleteAccountSetting" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteAccountSetting where
  toJSON :: DeleteAccountSetting -> Value
toJSON DeleteAccountSetting' {Maybe Text
SettingName
name :: SettingName
principalArn :: Maybe Text
$sel:name:DeleteAccountSetting' :: DeleteAccountSetting -> SettingName
$sel:principalArn:DeleteAccountSetting' :: DeleteAccountSetting -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"principalArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
principalArn,
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SettingName
name)
          ]
      )

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

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

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

-- |
-- Create a value of 'DeleteAccountSettingResponse' 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:
--
-- 'setting', 'deleteAccountSettingResponse_setting' - The account setting for the specified principal ARN.
--
-- 'httpStatus', 'deleteAccountSettingResponse_httpStatus' - The response's http status code.
newDeleteAccountSettingResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteAccountSettingResponse
newDeleteAccountSettingResponse :: Int -> DeleteAccountSettingResponse
newDeleteAccountSettingResponse Int
pHttpStatus_ =
  DeleteAccountSettingResponse'
    { $sel:setting:DeleteAccountSettingResponse' :: Maybe Setting
setting =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteAccountSettingResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The account setting for the specified principal ARN.
deleteAccountSettingResponse_setting :: Lens.Lens' DeleteAccountSettingResponse (Prelude.Maybe Setting)
deleteAccountSettingResponse_setting :: Lens' DeleteAccountSettingResponse (Maybe Setting)
deleteAccountSettingResponse_setting = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAccountSettingResponse' {Maybe Setting
setting :: Maybe Setting
$sel:setting:DeleteAccountSettingResponse' :: DeleteAccountSettingResponse -> Maybe Setting
setting} -> Maybe Setting
setting) (\s :: DeleteAccountSettingResponse
s@DeleteAccountSettingResponse' {} Maybe Setting
a -> DeleteAccountSettingResponse
s {$sel:setting:DeleteAccountSettingResponse' :: Maybe Setting
setting = Maybe Setting
a} :: DeleteAccountSettingResponse)

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

instance Prelude.NFData DeleteAccountSettingResponse where
  rnf :: DeleteAccountSettingResponse -> ()
rnf DeleteAccountSettingResponse' {Int
Maybe Setting
httpStatus :: Int
setting :: Maybe Setting
$sel:httpStatus:DeleteAccountSettingResponse' :: DeleteAccountSettingResponse -> Int
$sel:setting:DeleteAccountSettingResponse' :: DeleteAccountSettingResponse -> Maybe Setting
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Setting
setting
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus