{-# 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.CodeGuruReviewer.DisassociateRepository
-- 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 the association between Amazon CodeGuru Reviewer and a
-- repository.
module Amazonka.CodeGuruReviewer.DisassociateRepository
  ( -- * Creating a Request
    DisassociateRepository (..),
    newDisassociateRepository,

    -- * Request Lenses
    disassociateRepository_associationArn,

    -- * Destructuring the Response
    DisassociateRepositoryResponse (..),
    newDisassociateRepositoryResponse,

    -- * Response Lenses
    disassociateRepositoryResponse_repositoryAssociation,
    disassociateRepositoryResponse_tags,
    disassociateRepositoryResponse_httpStatus,
  )
where

import Amazonka.CodeGuruReviewer.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:/ 'newDisassociateRepository' smart constructor.
data DisassociateRepository = DisassociateRepository'
  { -- | The Amazon Resource Name (ARN) of the
    -- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_RepositoryAssociation.html RepositoryAssociation>
    -- object. You can retrieve this ARN by calling
    -- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_ListRepositoryAssociations.html ListRepositoryAssociations>.
    DisassociateRepository -> Text
associationArn :: Prelude.Text
  }
  deriving (DisassociateRepository -> DisassociateRepository -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateRepository -> DisassociateRepository -> Bool
$c/= :: DisassociateRepository -> DisassociateRepository -> Bool
== :: DisassociateRepository -> DisassociateRepository -> Bool
$c== :: DisassociateRepository -> DisassociateRepository -> Bool
Prelude.Eq, ReadPrec [DisassociateRepository]
ReadPrec DisassociateRepository
Int -> ReadS DisassociateRepository
ReadS [DisassociateRepository]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateRepository]
$creadListPrec :: ReadPrec [DisassociateRepository]
readPrec :: ReadPrec DisassociateRepository
$creadPrec :: ReadPrec DisassociateRepository
readList :: ReadS [DisassociateRepository]
$creadList :: ReadS [DisassociateRepository]
readsPrec :: Int -> ReadS DisassociateRepository
$creadsPrec :: Int -> ReadS DisassociateRepository
Prelude.Read, Int -> DisassociateRepository -> ShowS
[DisassociateRepository] -> ShowS
DisassociateRepository -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateRepository] -> ShowS
$cshowList :: [DisassociateRepository] -> ShowS
show :: DisassociateRepository -> String
$cshow :: DisassociateRepository -> String
showsPrec :: Int -> DisassociateRepository -> ShowS
$cshowsPrec :: Int -> DisassociateRepository -> ShowS
Prelude.Show, forall x. Rep DisassociateRepository x -> DisassociateRepository
forall x. DisassociateRepository -> Rep DisassociateRepository x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateRepository x -> DisassociateRepository
$cfrom :: forall x. DisassociateRepository -> Rep DisassociateRepository x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateRepository' 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:
--
-- 'associationArn', 'disassociateRepository_associationArn' - The Amazon Resource Name (ARN) of the
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_RepositoryAssociation.html RepositoryAssociation>
-- object. You can retrieve this ARN by calling
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_ListRepositoryAssociations.html ListRepositoryAssociations>.
newDisassociateRepository ::
  -- | 'associationArn'
  Prelude.Text ->
  DisassociateRepository
newDisassociateRepository :: Text -> DisassociateRepository
newDisassociateRepository Text
pAssociationArn_ =
  DisassociateRepository'
    { $sel:associationArn:DisassociateRepository' :: Text
associationArn =
        Text
pAssociationArn_
    }

-- | The Amazon Resource Name (ARN) of the
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_RepositoryAssociation.html RepositoryAssociation>
-- object. You can retrieve this ARN by calling
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_ListRepositoryAssociations.html ListRepositoryAssociations>.
disassociateRepository_associationArn :: Lens.Lens' DisassociateRepository Prelude.Text
disassociateRepository_associationArn :: Lens' DisassociateRepository Text
disassociateRepository_associationArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateRepository' {Text
associationArn :: Text
$sel:associationArn:DisassociateRepository' :: DisassociateRepository -> Text
associationArn} -> Text
associationArn) (\s :: DisassociateRepository
s@DisassociateRepository' {} Text
a -> DisassociateRepository
s {$sel:associationArn:DisassociateRepository' :: Text
associationArn = Text
a} :: DisassociateRepository)

instance Core.AWSRequest DisassociateRepository where
  type
    AWSResponse DisassociateRepository =
      DisassociateRepositoryResponse
  request :: (Service -> Service)
-> DisassociateRepository -> Request DisassociateRepository
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 DisassociateRepository
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateRepository)))
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 RepositoryAssociation
-> Maybe (HashMap Text Text)
-> Int
-> DisassociateRepositoryResponse
DisassociateRepositoryResponse'
            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
"RepositoryAssociation")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Tags" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 DisassociateRepository where
  hashWithSalt :: Int -> DisassociateRepository -> Int
hashWithSalt Int
_salt DisassociateRepository' {Text
associationArn :: Text
$sel:associationArn:DisassociateRepository' :: DisassociateRepository -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
associationArn

instance Prelude.NFData DisassociateRepository where
  rnf :: DisassociateRepository -> ()
rnf DisassociateRepository' {Text
associationArn :: Text
$sel:associationArn:DisassociateRepository' :: DisassociateRepository -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
associationArn

instance Data.ToHeaders DisassociateRepository where
  toHeaders :: DisassociateRepository -> 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 DisassociateRepository where
  toPath :: DisassociateRepository -> ByteString
toPath DisassociateRepository' {Text
associationArn :: Text
$sel:associationArn:DisassociateRepository' :: DisassociateRepository -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/associations/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
associationArn]

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

-- | /See:/ 'newDisassociateRepositoryResponse' smart constructor.
data DisassociateRepositoryResponse = DisassociateRepositoryResponse'
  { -- | Information about the disassociated repository.
    DisassociateRepositoryResponse -> Maybe RepositoryAssociation
repositoryAssociation :: Prelude.Maybe RepositoryAssociation,
    -- | An array of key-value pairs used to tag an associated repository. A tag
    -- is a custom attribute label with two parts:
    --
    -- -   A /tag key/ (for example, @CostCenter@, @Environment@, @Project@, or
    --     @Secret@). Tag keys are case sensitive.
    --
    -- -   An optional field known as a /tag value/ (for example,
    --     @111122223333@, @Production@, or a team name). Omitting the tag
    --     value is the same as using an empty string. Like tag keys, tag
    --     values are case sensitive.
    DisassociateRepositoryResponse -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The response's http status code.
    DisassociateRepositoryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DisassociateRepositoryResponse
-> DisassociateRepositoryResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateRepositoryResponse
-> DisassociateRepositoryResponse -> Bool
$c/= :: DisassociateRepositoryResponse
-> DisassociateRepositoryResponse -> Bool
== :: DisassociateRepositoryResponse
-> DisassociateRepositoryResponse -> Bool
$c== :: DisassociateRepositoryResponse
-> DisassociateRepositoryResponse -> Bool
Prelude.Eq, ReadPrec [DisassociateRepositoryResponse]
ReadPrec DisassociateRepositoryResponse
Int -> ReadS DisassociateRepositoryResponse
ReadS [DisassociateRepositoryResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateRepositoryResponse]
$creadListPrec :: ReadPrec [DisassociateRepositoryResponse]
readPrec :: ReadPrec DisassociateRepositoryResponse
$creadPrec :: ReadPrec DisassociateRepositoryResponse
readList :: ReadS [DisassociateRepositoryResponse]
$creadList :: ReadS [DisassociateRepositoryResponse]
readsPrec :: Int -> ReadS DisassociateRepositoryResponse
$creadsPrec :: Int -> ReadS DisassociateRepositoryResponse
Prelude.Read, Int -> DisassociateRepositoryResponse -> ShowS
[DisassociateRepositoryResponse] -> ShowS
DisassociateRepositoryResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateRepositoryResponse] -> ShowS
$cshowList :: [DisassociateRepositoryResponse] -> ShowS
show :: DisassociateRepositoryResponse -> String
$cshow :: DisassociateRepositoryResponse -> String
showsPrec :: Int -> DisassociateRepositoryResponse -> ShowS
$cshowsPrec :: Int -> DisassociateRepositoryResponse -> ShowS
Prelude.Show, forall x.
Rep DisassociateRepositoryResponse x
-> DisassociateRepositoryResponse
forall x.
DisassociateRepositoryResponse
-> Rep DisassociateRepositoryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateRepositoryResponse x
-> DisassociateRepositoryResponse
$cfrom :: forall x.
DisassociateRepositoryResponse
-> Rep DisassociateRepositoryResponse x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateRepositoryResponse' 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:
--
-- 'repositoryAssociation', 'disassociateRepositoryResponse_repositoryAssociation' - Information about the disassociated repository.
--
-- 'tags', 'disassociateRepositoryResponse_tags' - An array of key-value pairs used to tag an associated repository. A tag
-- is a custom attribute label with two parts:
--
-- -   A /tag key/ (for example, @CostCenter@, @Environment@, @Project@, or
--     @Secret@). Tag keys are case sensitive.
--
-- -   An optional field known as a /tag value/ (for example,
--     @111122223333@, @Production@, or a team name). Omitting the tag
--     value is the same as using an empty string. Like tag keys, tag
--     values are case sensitive.
--
-- 'httpStatus', 'disassociateRepositoryResponse_httpStatus' - The response's http status code.
newDisassociateRepositoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateRepositoryResponse
newDisassociateRepositoryResponse :: Int -> DisassociateRepositoryResponse
newDisassociateRepositoryResponse Int
pHttpStatus_ =
  DisassociateRepositoryResponse'
    { $sel:repositoryAssociation:DisassociateRepositoryResponse' :: Maybe RepositoryAssociation
repositoryAssociation =
        forall a. Maybe a
Prelude.Nothing,
      $sel:tags:DisassociateRepositoryResponse' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisassociateRepositoryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the disassociated repository.
disassociateRepositoryResponse_repositoryAssociation :: Lens.Lens' DisassociateRepositoryResponse (Prelude.Maybe RepositoryAssociation)
disassociateRepositoryResponse_repositoryAssociation :: Lens' DisassociateRepositoryResponse (Maybe RepositoryAssociation)
disassociateRepositoryResponse_repositoryAssociation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateRepositoryResponse' {Maybe RepositoryAssociation
repositoryAssociation :: Maybe RepositoryAssociation
$sel:repositoryAssociation:DisassociateRepositoryResponse' :: DisassociateRepositoryResponse -> Maybe RepositoryAssociation
repositoryAssociation} -> Maybe RepositoryAssociation
repositoryAssociation) (\s :: DisassociateRepositoryResponse
s@DisassociateRepositoryResponse' {} Maybe RepositoryAssociation
a -> DisassociateRepositoryResponse
s {$sel:repositoryAssociation:DisassociateRepositoryResponse' :: Maybe RepositoryAssociation
repositoryAssociation = Maybe RepositoryAssociation
a} :: DisassociateRepositoryResponse)

-- | An array of key-value pairs used to tag an associated repository. A tag
-- is a custom attribute label with two parts:
--
-- -   A /tag key/ (for example, @CostCenter@, @Environment@, @Project@, or
--     @Secret@). Tag keys are case sensitive.
--
-- -   An optional field known as a /tag value/ (for example,
--     @111122223333@, @Production@, or a team name). Omitting the tag
--     value is the same as using an empty string. Like tag keys, tag
--     values are case sensitive.
disassociateRepositoryResponse_tags :: Lens.Lens' DisassociateRepositoryResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
disassociateRepositoryResponse_tags :: Lens' DisassociateRepositoryResponse (Maybe (HashMap Text Text))
disassociateRepositoryResponse_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateRepositoryResponse' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:DisassociateRepositoryResponse' :: DisassociateRepositoryResponse -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: DisassociateRepositoryResponse
s@DisassociateRepositoryResponse' {} Maybe (HashMap Text Text)
a -> DisassociateRepositoryResponse
s {$sel:tags:DisassociateRepositoryResponse' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: DisassociateRepositoryResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    DisassociateRepositoryResponse
  where
  rnf :: DisassociateRepositoryResponse -> ()
rnf DisassociateRepositoryResponse' {Int
Maybe (HashMap Text Text)
Maybe RepositoryAssociation
httpStatus :: Int
tags :: Maybe (HashMap Text Text)
repositoryAssociation :: Maybe RepositoryAssociation
$sel:httpStatus:DisassociateRepositoryResponse' :: DisassociateRepositoryResponse -> Int
$sel:tags:DisassociateRepositoryResponse' :: DisassociateRepositoryResponse -> Maybe (HashMap Text Text)
$sel:repositoryAssociation:DisassociateRepositoryResponse' :: DisassociateRepositoryResponse -> Maybe RepositoryAssociation
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RepositoryAssociation
repositoryAssociation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus