{-# 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-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)
--
-- 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 Amazonka.ECS.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:/ 'newDeleteAccountSetting' smart constructor.
data DeleteAccountSetting = DeleteAccountSetting'
  { -- | The ARN of the principal, which 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 for which to disable the account setting. 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
(DeleteAccountSetting -> DeleteAccountSetting -> Bool)
-> (DeleteAccountSetting -> DeleteAccountSetting -> Bool)
-> Eq DeleteAccountSetting
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]
(Int -> ReadS DeleteAccountSetting)
-> ReadS [DeleteAccountSetting]
-> ReadPrec DeleteAccountSetting
-> ReadPrec [DeleteAccountSetting]
-> Read 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
(Int -> DeleteAccountSetting -> ShowS)
-> (DeleteAccountSetting -> String)
-> ([DeleteAccountSetting] -> ShowS)
-> Show DeleteAccountSetting
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. DeleteAccountSetting -> Rep DeleteAccountSetting x)
-> (forall x. Rep DeleteAccountSetting x -> DeleteAccountSetting)
-> Generic DeleteAccountSetting
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 ARN of the principal, which 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 for which to disable the account setting. 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' :: Maybe Text -> SettingName -> DeleteAccountSetting
DeleteAccountSetting'
    { $sel:principalArn:DeleteAccountSetting' :: Maybe Text
principalArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:DeleteAccountSetting' :: SettingName
name = SettingName
pName_
    }

-- | The ARN of the principal, which 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 :: (Maybe Text -> f (Maybe Text))
-> DeleteAccountSetting -> f DeleteAccountSetting
deleteAccountSetting_principalArn = (DeleteAccountSetting -> Maybe Text)
-> (DeleteAccountSetting -> Maybe Text -> DeleteAccountSetting)
-> Lens
     DeleteAccountSetting DeleteAccountSetting (Maybe Text) (Maybe Text)
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 for which to disable the account setting. 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 :: (SettingName -> f SettingName)
-> DeleteAccountSetting -> f DeleteAccountSetting
deleteAccountSetting_name = (DeleteAccountSetting -> SettingName)
-> (DeleteAccountSetting -> SettingName -> DeleteAccountSetting)
-> Lens
     DeleteAccountSetting DeleteAccountSetting SettingName SettingName
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 :: DeleteAccountSetting -> Request DeleteAccountSetting
request = Service -> DeleteAccountSetting -> Request DeleteAccountSetting
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteAccountSetting
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteAccountSetting)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteAccountSetting))
-> Logger
-> Service
-> Proxy DeleteAccountSetting
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteAccountSetting)))
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 Setting -> Int -> DeleteAccountSettingResponse
DeleteAccountSettingResponse'
            (Maybe Setting -> Int -> DeleteAccountSettingResponse)
-> Either String (Maybe Setting)
-> Either String (Int -> DeleteAccountSettingResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Setting)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"setting")
            Either String (Int -> DeleteAccountSettingResponse)
-> Either String Int -> Either String DeleteAccountSettingResponse
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 DeleteAccountSetting

instance Prelude.NFData DeleteAccountSetting

instance Core.ToHeaders DeleteAccountSetting where
  toHeaders :: DeleteAccountSetting -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteAccountSetting -> 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
"AmazonEC2ContainerServiceV20141113.DeleteAccountSetting" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"principalArn" 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
principalArn,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> SettingName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SettingName
name)
          ]
      )

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

instance Core.ToQuery DeleteAccountSetting where
  toQuery :: DeleteAccountSetting -> QueryString
toQuery = QueryString -> DeleteAccountSetting -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteAccountSettingResponse
 -> DeleteAccountSettingResponse -> Bool)
-> (DeleteAccountSettingResponse
    -> DeleteAccountSettingResponse -> Bool)
-> Eq DeleteAccountSettingResponse
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]
(Int -> ReadS DeleteAccountSettingResponse)
-> ReadS [DeleteAccountSettingResponse]
-> ReadPrec DeleteAccountSettingResponse
-> ReadPrec [DeleteAccountSettingResponse]
-> Read 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
(Int -> DeleteAccountSettingResponse -> ShowS)
-> (DeleteAccountSettingResponse -> String)
-> ([DeleteAccountSettingResponse] -> ShowS)
-> Show DeleteAccountSettingResponse
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.
 DeleteAccountSettingResponse -> Rep DeleteAccountSettingResponse x)
-> (forall x.
    Rep DeleteAccountSettingResponse x -> DeleteAccountSettingResponse)
-> Generic DeleteAccountSettingResponse
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' :: Maybe Setting -> Int -> DeleteAccountSettingResponse
DeleteAccountSettingResponse'
    { $sel:setting:DeleteAccountSettingResponse' :: Maybe Setting
setting =
        Maybe 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 :: (Maybe Setting -> f (Maybe Setting))
-> DeleteAccountSettingResponse -> f DeleteAccountSettingResponse
deleteAccountSettingResponse_setting = (DeleteAccountSettingResponse -> Maybe Setting)
-> (DeleteAccountSettingResponse
    -> Maybe Setting -> DeleteAccountSettingResponse)
-> Lens
     DeleteAccountSettingResponse
     DeleteAccountSettingResponse
     (Maybe Setting)
     (Maybe 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 :: (Int -> f Int)
-> DeleteAccountSettingResponse -> f DeleteAccountSettingResponse
deleteAccountSettingResponse_httpStatus = (DeleteAccountSettingResponse -> Int)
-> (DeleteAccountSettingResponse
    -> Int -> DeleteAccountSettingResponse)
-> Lens
     DeleteAccountSettingResponse DeleteAccountSettingResponse Int Int
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