{-# 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.CodeArtifact.DisassociateExternalConnection
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes an existing external connection from a repository.
module Amazonka.CodeArtifact.DisassociateExternalConnection
  ( -- * Creating a Request
    DisassociateExternalConnection (..),
    newDisassociateExternalConnection,

    -- * Request Lenses
    disassociateExternalConnection_domainOwner,
    disassociateExternalConnection_domain,
    disassociateExternalConnection_repository,
    disassociateExternalConnection_externalConnection,

    -- * Destructuring the Response
    DisassociateExternalConnectionResponse (..),
    newDisassociateExternalConnectionResponse,

    -- * Response Lenses
    disassociateExternalConnectionResponse_repository,
    disassociateExternalConnectionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDisassociateExternalConnection' smart constructor.
data DisassociateExternalConnection = DisassociateExternalConnection'
  { -- | The 12-digit account number of the Amazon Web Services account that owns
    -- the domain. It does not include dashes or spaces.
    DisassociateExternalConnection -> Maybe Text
domainOwner :: Prelude.Maybe Prelude.Text,
    -- | The name of the domain that contains the repository from which to remove
    -- the external repository.
    DisassociateExternalConnection -> Text
domain :: Prelude.Text,
    -- | The name of the repository from which the external connection will be
    -- removed.
    DisassociateExternalConnection -> Text
repository :: Prelude.Text,
    -- | The name of the external connection to be removed from the repository.
    DisassociateExternalConnection -> Text
externalConnection :: Prelude.Text
  }
  deriving (DisassociateExternalConnection
-> DisassociateExternalConnection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateExternalConnection
-> DisassociateExternalConnection -> Bool
$c/= :: DisassociateExternalConnection
-> DisassociateExternalConnection -> Bool
== :: DisassociateExternalConnection
-> DisassociateExternalConnection -> Bool
$c== :: DisassociateExternalConnection
-> DisassociateExternalConnection -> Bool
Prelude.Eq, ReadPrec [DisassociateExternalConnection]
ReadPrec DisassociateExternalConnection
Int -> ReadS DisassociateExternalConnection
ReadS [DisassociateExternalConnection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateExternalConnection]
$creadListPrec :: ReadPrec [DisassociateExternalConnection]
readPrec :: ReadPrec DisassociateExternalConnection
$creadPrec :: ReadPrec DisassociateExternalConnection
readList :: ReadS [DisassociateExternalConnection]
$creadList :: ReadS [DisassociateExternalConnection]
readsPrec :: Int -> ReadS DisassociateExternalConnection
$creadsPrec :: Int -> ReadS DisassociateExternalConnection
Prelude.Read, Int -> DisassociateExternalConnection -> ShowS
[DisassociateExternalConnection] -> ShowS
DisassociateExternalConnection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateExternalConnection] -> ShowS
$cshowList :: [DisassociateExternalConnection] -> ShowS
show :: DisassociateExternalConnection -> String
$cshow :: DisassociateExternalConnection -> String
showsPrec :: Int -> DisassociateExternalConnection -> ShowS
$cshowsPrec :: Int -> DisassociateExternalConnection -> ShowS
Prelude.Show, forall x.
Rep DisassociateExternalConnection x
-> DisassociateExternalConnection
forall x.
DisassociateExternalConnection
-> Rep DisassociateExternalConnection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateExternalConnection x
-> DisassociateExternalConnection
$cfrom :: forall x.
DisassociateExternalConnection
-> Rep DisassociateExternalConnection x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateExternalConnection' 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:
--
-- 'domainOwner', 'disassociateExternalConnection_domainOwner' - The 12-digit account number of the Amazon Web Services account that owns
-- the domain. It does not include dashes or spaces.
--
-- 'domain', 'disassociateExternalConnection_domain' - The name of the domain that contains the repository from which to remove
-- the external repository.
--
-- 'repository', 'disassociateExternalConnection_repository' - The name of the repository from which the external connection will be
-- removed.
--
-- 'externalConnection', 'disassociateExternalConnection_externalConnection' - The name of the external connection to be removed from the repository.
newDisassociateExternalConnection ::
  -- | 'domain'
  Prelude.Text ->
  -- | 'repository'
  Prelude.Text ->
  -- | 'externalConnection'
  Prelude.Text ->
  DisassociateExternalConnection
newDisassociateExternalConnection :: Text -> Text -> Text -> DisassociateExternalConnection
newDisassociateExternalConnection
  Text
pDomain_
  Text
pRepository_
  Text
pExternalConnection_ =
    DisassociateExternalConnection'
      { $sel:domainOwner:DisassociateExternalConnection' :: Maybe Text
domainOwner =
          forall a. Maybe a
Prelude.Nothing,
        $sel:domain:DisassociateExternalConnection' :: Text
domain = Text
pDomain_,
        $sel:repository:DisassociateExternalConnection' :: Text
repository = Text
pRepository_,
        $sel:externalConnection:DisassociateExternalConnection' :: Text
externalConnection = Text
pExternalConnection_
      }

-- | The 12-digit account number of the Amazon Web Services account that owns
-- the domain. It does not include dashes or spaces.
disassociateExternalConnection_domainOwner :: Lens.Lens' DisassociateExternalConnection (Prelude.Maybe Prelude.Text)
disassociateExternalConnection_domainOwner :: Lens' DisassociateExternalConnection (Maybe Text)
disassociateExternalConnection_domainOwner = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateExternalConnection' {Maybe Text
domainOwner :: Maybe Text
$sel:domainOwner:DisassociateExternalConnection' :: DisassociateExternalConnection -> Maybe Text
domainOwner} -> Maybe Text
domainOwner) (\s :: DisassociateExternalConnection
s@DisassociateExternalConnection' {} Maybe Text
a -> DisassociateExternalConnection
s {$sel:domainOwner:DisassociateExternalConnection' :: Maybe Text
domainOwner = Maybe Text
a} :: DisassociateExternalConnection)

-- | The name of the domain that contains the repository from which to remove
-- the external repository.
disassociateExternalConnection_domain :: Lens.Lens' DisassociateExternalConnection Prelude.Text
disassociateExternalConnection_domain :: Lens' DisassociateExternalConnection Text
disassociateExternalConnection_domain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateExternalConnection' {Text
domain :: Text
$sel:domain:DisassociateExternalConnection' :: DisassociateExternalConnection -> Text
domain} -> Text
domain) (\s :: DisassociateExternalConnection
s@DisassociateExternalConnection' {} Text
a -> DisassociateExternalConnection
s {$sel:domain:DisassociateExternalConnection' :: Text
domain = Text
a} :: DisassociateExternalConnection)

-- | The name of the repository from which the external connection will be
-- removed.
disassociateExternalConnection_repository :: Lens.Lens' DisassociateExternalConnection Prelude.Text
disassociateExternalConnection_repository :: Lens' DisassociateExternalConnection Text
disassociateExternalConnection_repository = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateExternalConnection' {Text
repository :: Text
$sel:repository:DisassociateExternalConnection' :: DisassociateExternalConnection -> Text
repository} -> Text
repository) (\s :: DisassociateExternalConnection
s@DisassociateExternalConnection' {} Text
a -> DisassociateExternalConnection
s {$sel:repository:DisassociateExternalConnection' :: Text
repository = Text
a} :: DisassociateExternalConnection)

-- | The name of the external connection to be removed from the repository.
disassociateExternalConnection_externalConnection :: Lens.Lens' DisassociateExternalConnection Prelude.Text
disassociateExternalConnection_externalConnection :: Lens' DisassociateExternalConnection Text
disassociateExternalConnection_externalConnection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateExternalConnection' {Text
externalConnection :: Text
$sel:externalConnection:DisassociateExternalConnection' :: DisassociateExternalConnection -> Text
externalConnection} -> Text
externalConnection) (\s :: DisassociateExternalConnection
s@DisassociateExternalConnection' {} Text
a -> DisassociateExternalConnection
s {$sel:externalConnection:DisassociateExternalConnection' :: Text
externalConnection = Text
a} :: DisassociateExternalConnection)

instance
  Core.AWSRequest
    DisassociateExternalConnection
  where
  type
    AWSResponse DisassociateExternalConnection =
      DisassociateExternalConnectionResponse
  request :: (Service -> Service)
-> DisassociateExternalConnection
-> Request DisassociateExternalConnection
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DisassociateExternalConnection
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DisassociateExternalConnection)))
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 RepositoryDescription
-> Int -> DisassociateExternalConnectionResponse
DisassociateExternalConnectionResponse'
            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
"repository")
            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
    DisassociateExternalConnection
  where
  hashWithSalt :: Int -> DisassociateExternalConnection -> Int
hashWithSalt
    Int
_salt
    DisassociateExternalConnection' {Maybe Text
Text
externalConnection :: Text
repository :: Text
domain :: Text
domainOwner :: Maybe Text
$sel:externalConnection:DisassociateExternalConnection' :: DisassociateExternalConnection -> Text
$sel:repository:DisassociateExternalConnection' :: DisassociateExternalConnection -> Text
$sel:domain:DisassociateExternalConnection' :: DisassociateExternalConnection -> Text
$sel:domainOwner:DisassociateExternalConnection' :: DisassociateExternalConnection -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
domainOwner
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domain
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
repository
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
externalConnection

instance
  Prelude.NFData
    DisassociateExternalConnection
  where
  rnf :: DisassociateExternalConnection -> ()
rnf DisassociateExternalConnection' {Maybe Text
Text
externalConnection :: Text
repository :: Text
domain :: Text
domainOwner :: Maybe Text
$sel:externalConnection:DisassociateExternalConnection' :: DisassociateExternalConnection -> Text
$sel:repository:DisassociateExternalConnection' :: DisassociateExternalConnection -> Text
$sel:domain:DisassociateExternalConnection' :: DisassociateExternalConnection -> Text
$sel:domainOwner:DisassociateExternalConnection' :: DisassociateExternalConnection -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
domainOwner
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
domain
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
repository
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
externalConnection

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

instance Data.ToPath DisassociateExternalConnection where
  toPath :: DisassociateExternalConnection -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const ByteString
"/v1/repository/external-connection"

instance Data.ToQuery DisassociateExternalConnection where
  toQuery :: DisassociateExternalConnection -> QueryString
toQuery DisassociateExternalConnection' {Maybe Text
Text
externalConnection :: Text
repository :: Text
domain :: Text
domainOwner :: Maybe Text
$sel:externalConnection:DisassociateExternalConnection' :: DisassociateExternalConnection -> Text
$sel:repository:DisassociateExternalConnection' :: DisassociateExternalConnection -> Text
$sel:domain:DisassociateExternalConnection' :: DisassociateExternalConnection -> Text
$sel:domainOwner:DisassociateExternalConnection' :: DisassociateExternalConnection -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"domain-owner" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
domainOwner,
        ByteString
"domain" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
domain,
        ByteString
"repository" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
repository,
        ByteString
"external-connection" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
externalConnection
      ]

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

-- |
-- Create a value of 'DisassociateExternalConnectionResponse' 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:
--
-- 'repository', 'disassociateExternalConnectionResponse_repository' - The repository associated with the removed external connection.
--
-- 'httpStatus', 'disassociateExternalConnectionResponse_httpStatus' - The response's http status code.
newDisassociateExternalConnectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateExternalConnectionResponse
newDisassociateExternalConnectionResponse :: Int -> DisassociateExternalConnectionResponse
newDisassociateExternalConnectionResponse
  Int
pHttpStatus_ =
    DisassociateExternalConnectionResponse'
      { $sel:repository:DisassociateExternalConnectionResponse' :: Maybe RepositoryDescription
repository =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DisassociateExternalConnectionResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The repository associated with the removed external connection.
disassociateExternalConnectionResponse_repository :: Lens.Lens' DisassociateExternalConnectionResponse (Prelude.Maybe RepositoryDescription)
disassociateExternalConnectionResponse_repository :: Lens'
  DisassociateExternalConnectionResponse
  (Maybe RepositoryDescription)
disassociateExternalConnectionResponse_repository = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateExternalConnectionResponse' {Maybe RepositoryDescription
repository :: Maybe RepositoryDescription
$sel:repository:DisassociateExternalConnectionResponse' :: DisassociateExternalConnectionResponse
-> Maybe RepositoryDescription
repository} -> Maybe RepositoryDescription
repository) (\s :: DisassociateExternalConnectionResponse
s@DisassociateExternalConnectionResponse' {} Maybe RepositoryDescription
a -> DisassociateExternalConnectionResponse
s {$sel:repository:DisassociateExternalConnectionResponse' :: Maybe RepositoryDescription
repository = Maybe RepositoryDescription
a} :: DisassociateExternalConnectionResponse)

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

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