{-# 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.CodeCommit.GetDifferences
-- 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)
--
-- Returns information about the differences in a valid commit specifier
-- (such as a branch, tag, HEAD, commit ID, or other fully qualified
-- reference). Results can be limited to a specified path.
--
-- This operation returns paginated results.
module Amazonka.CodeCommit.GetDifferences
  ( -- * Creating a Request
    GetDifferences (..),
    newGetDifferences,

    -- * Request Lenses
    getDifferences_afterPath,
    getDifferences_nextToken,
    getDifferences_beforeCommitSpecifier,
    getDifferences_beforePath,
    getDifferences_maxResults,
    getDifferences_repositoryName,
    getDifferences_afterCommitSpecifier,

    -- * Destructuring the Response
    GetDifferencesResponse (..),
    newGetDifferencesResponse,

    -- * Response Lenses
    getDifferencesResponse_nextToken,
    getDifferencesResponse_differences,
    getDifferencesResponse_httpStatus,
  )
where

import Amazonka.CodeCommit.Types
import qualified Amazonka.Core as Core
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:/ 'newGetDifferences' smart constructor.
data GetDifferences = GetDifferences'
  { -- | The file path in which to check differences. Limits the results to this
    -- path. Can also be used to specify the changed name of a directory or
    -- folder, if it has changed. If not specified, differences are shown for
    -- all paths.
    GetDifferences -> Maybe Text
afterPath :: Prelude.Maybe Prelude.Text,
    -- | An enumeration token that, when provided in a request, returns the next
    -- batch of the results.
    GetDifferences -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The branch, tag, HEAD, or other fully qualified reference used to
    -- identify a commit (for example, the full commit ID). Optional. If not
    -- specified, all changes before the @afterCommitSpecifier@ value are
    -- shown. If you do not use @beforeCommitSpecifier@ in your request,
    -- consider limiting the results with @maxResults@.
    GetDifferences -> Maybe Text
beforeCommitSpecifier :: Prelude.Maybe Prelude.Text,
    -- | The file path in which to check for differences. Limits the results to
    -- this path. Can also be used to specify the previous name of a directory
    -- or folder. If @beforePath@ and @afterPath@ are not specified,
    -- differences are shown for all paths.
    GetDifferences -> Maybe Text
beforePath :: Prelude.Maybe Prelude.Text,
    -- | A non-zero, non-negative integer used to limit the number of returned
    -- results.
    GetDifferences -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int,
    -- | The name of the repository where you want to get differences.
    GetDifferences -> Text
repositoryName :: Prelude.Text,
    -- | The branch, tag, HEAD, or other fully qualified reference used to
    -- identify a commit.
    GetDifferences -> Text
afterCommitSpecifier :: Prelude.Text
  }
  deriving (GetDifferences -> GetDifferences -> Bool
(GetDifferences -> GetDifferences -> Bool)
-> (GetDifferences -> GetDifferences -> Bool) -> Eq GetDifferences
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDifferences -> GetDifferences -> Bool
$c/= :: GetDifferences -> GetDifferences -> Bool
== :: GetDifferences -> GetDifferences -> Bool
$c== :: GetDifferences -> GetDifferences -> Bool
Prelude.Eq, ReadPrec [GetDifferences]
ReadPrec GetDifferences
Int -> ReadS GetDifferences
ReadS [GetDifferences]
(Int -> ReadS GetDifferences)
-> ReadS [GetDifferences]
-> ReadPrec GetDifferences
-> ReadPrec [GetDifferences]
-> Read GetDifferences
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDifferences]
$creadListPrec :: ReadPrec [GetDifferences]
readPrec :: ReadPrec GetDifferences
$creadPrec :: ReadPrec GetDifferences
readList :: ReadS [GetDifferences]
$creadList :: ReadS [GetDifferences]
readsPrec :: Int -> ReadS GetDifferences
$creadsPrec :: Int -> ReadS GetDifferences
Prelude.Read, Int -> GetDifferences -> ShowS
[GetDifferences] -> ShowS
GetDifferences -> String
(Int -> GetDifferences -> ShowS)
-> (GetDifferences -> String)
-> ([GetDifferences] -> ShowS)
-> Show GetDifferences
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDifferences] -> ShowS
$cshowList :: [GetDifferences] -> ShowS
show :: GetDifferences -> String
$cshow :: GetDifferences -> String
showsPrec :: Int -> GetDifferences -> ShowS
$cshowsPrec :: Int -> GetDifferences -> ShowS
Prelude.Show, (forall x. GetDifferences -> Rep GetDifferences x)
-> (forall x. Rep GetDifferences x -> GetDifferences)
-> Generic GetDifferences
forall x. Rep GetDifferences x -> GetDifferences
forall x. GetDifferences -> Rep GetDifferences x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDifferences x -> GetDifferences
$cfrom :: forall x. GetDifferences -> Rep GetDifferences x
Prelude.Generic)

-- |
-- Create a value of 'GetDifferences' 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:
--
-- 'afterPath', 'getDifferences_afterPath' - The file path in which to check differences. Limits the results to this
-- path. Can also be used to specify the changed name of a directory or
-- folder, if it has changed. If not specified, differences are shown for
-- all paths.
--
-- 'nextToken', 'getDifferences_nextToken' - An enumeration token that, when provided in a request, returns the next
-- batch of the results.
--
-- 'beforeCommitSpecifier', 'getDifferences_beforeCommitSpecifier' - The branch, tag, HEAD, or other fully qualified reference used to
-- identify a commit (for example, the full commit ID). Optional. If not
-- specified, all changes before the @afterCommitSpecifier@ value are
-- shown. If you do not use @beforeCommitSpecifier@ in your request,
-- consider limiting the results with @maxResults@.
--
-- 'beforePath', 'getDifferences_beforePath' - The file path in which to check for differences. Limits the results to
-- this path. Can also be used to specify the previous name of a directory
-- or folder. If @beforePath@ and @afterPath@ are not specified,
-- differences are shown for all paths.
--
-- 'maxResults', 'getDifferences_maxResults' - A non-zero, non-negative integer used to limit the number of returned
-- results.
--
-- 'repositoryName', 'getDifferences_repositoryName' - The name of the repository where you want to get differences.
--
-- 'afterCommitSpecifier', 'getDifferences_afterCommitSpecifier' - The branch, tag, HEAD, or other fully qualified reference used to
-- identify a commit.
newGetDifferences ::
  -- | 'repositoryName'
  Prelude.Text ->
  -- | 'afterCommitSpecifier'
  Prelude.Text ->
  GetDifferences
newGetDifferences :: Text -> Text -> GetDifferences
newGetDifferences
  Text
pRepositoryName_
  Text
pAfterCommitSpecifier_ =
    GetDifferences' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Text
-> Text
-> GetDifferences
GetDifferences'
      { $sel:afterPath:GetDifferences' :: Maybe Text
afterPath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:GetDifferences' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:beforeCommitSpecifier:GetDifferences' :: Maybe Text
beforeCommitSpecifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:beforePath:GetDifferences' :: Maybe Text
beforePath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:GetDifferences' :: Maybe Int
maxResults = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:repositoryName:GetDifferences' :: Text
repositoryName = Text
pRepositoryName_,
        $sel:afterCommitSpecifier:GetDifferences' :: Text
afterCommitSpecifier = Text
pAfterCommitSpecifier_
      }

-- | The file path in which to check differences. Limits the results to this
-- path. Can also be used to specify the changed name of a directory or
-- folder, if it has changed. If not specified, differences are shown for
-- all paths.
getDifferences_afterPath :: Lens.Lens' GetDifferences (Prelude.Maybe Prelude.Text)
getDifferences_afterPath :: (Maybe Text -> f (Maybe Text))
-> GetDifferences -> f GetDifferences
getDifferences_afterPath = (GetDifferences -> Maybe Text)
-> (GetDifferences -> Maybe Text -> GetDifferences)
-> Lens GetDifferences GetDifferences (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDifferences' {Maybe Text
afterPath :: Maybe Text
$sel:afterPath:GetDifferences' :: GetDifferences -> Maybe Text
afterPath} -> Maybe Text
afterPath) (\s :: GetDifferences
s@GetDifferences' {} Maybe Text
a -> GetDifferences
s {$sel:afterPath:GetDifferences' :: Maybe Text
afterPath = Maybe Text
a} :: GetDifferences)

-- | An enumeration token that, when provided in a request, returns the next
-- batch of the results.
getDifferences_nextToken :: Lens.Lens' GetDifferences (Prelude.Maybe Prelude.Text)
getDifferences_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetDifferences -> f GetDifferences
getDifferences_nextToken = (GetDifferences -> Maybe Text)
-> (GetDifferences -> Maybe Text -> GetDifferences)
-> Lens GetDifferences GetDifferences (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDifferences' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetDifferences' :: GetDifferences -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetDifferences
s@GetDifferences' {} Maybe Text
a -> GetDifferences
s {$sel:nextToken:GetDifferences' :: Maybe Text
nextToken = Maybe Text
a} :: GetDifferences)

-- | The branch, tag, HEAD, or other fully qualified reference used to
-- identify a commit (for example, the full commit ID). Optional. If not
-- specified, all changes before the @afterCommitSpecifier@ value are
-- shown. If you do not use @beforeCommitSpecifier@ in your request,
-- consider limiting the results with @maxResults@.
getDifferences_beforeCommitSpecifier :: Lens.Lens' GetDifferences (Prelude.Maybe Prelude.Text)
getDifferences_beforeCommitSpecifier :: (Maybe Text -> f (Maybe Text))
-> GetDifferences -> f GetDifferences
getDifferences_beforeCommitSpecifier = (GetDifferences -> Maybe Text)
-> (GetDifferences -> Maybe Text -> GetDifferences)
-> Lens GetDifferences GetDifferences (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDifferences' {Maybe Text
beforeCommitSpecifier :: Maybe Text
$sel:beforeCommitSpecifier:GetDifferences' :: GetDifferences -> Maybe Text
beforeCommitSpecifier} -> Maybe Text
beforeCommitSpecifier) (\s :: GetDifferences
s@GetDifferences' {} Maybe Text
a -> GetDifferences
s {$sel:beforeCommitSpecifier:GetDifferences' :: Maybe Text
beforeCommitSpecifier = Maybe Text
a} :: GetDifferences)

-- | The file path in which to check for differences. Limits the results to
-- this path. Can also be used to specify the previous name of a directory
-- or folder. If @beforePath@ and @afterPath@ are not specified,
-- differences are shown for all paths.
getDifferences_beforePath :: Lens.Lens' GetDifferences (Prelude.Maybe Prelude.Text)
getDifferences_beforePath :: (Maybe Text -> f (Maybe Text))
-> GetDifferences -> f GetDifferences
getDifferences_beforePath = (GetDifferences -> Maybe Text)
-> (GetDifferences -> Maybe Text -> GetDifferences)
-> Lens GetDifferences GetDifferences (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDifferences' {Maybe Text
beforePath :: Maybe Text
$sel:beforePath:GetDifferences' :: GetDifferences -> Maybe Text
beforePath} -> Maybe Text
beforePath) (\s :: GetDifferences
s@GetDifferences' {} Maybe Text
a -> GetDifferences
s {$sel:beforePath:GetDifferences' :: Maybe Text
beforePath = Maybe Text
a} :: GetDifferences)

-- | A non-zero, non-negative integer used to limit the number of returned
-- results.
getDifferences_maxResults :: Lens.Lens' GetDifferences (Prelude.Maybe Prelude.Int)
getDifferences_maxResults :: (Maybe Int -> f (Maybe Int)) -> GetDifferences -> f GetDifferences
getDifferences_maxResults = (GetDifferences -> Maybe Int)
-> (GetDifferences -> Maybe Int -> GetDifferences)
-> Lens GetDifferences GetDifferences (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDifferences' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:GetDifferences' :: GetDifferences -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: GetDifferences
s@GetDifferences' {} Maybe Int
a -> GetDifferences
s {$sel:maxResults:GetDifferences' :: Maybe Int
maxResults = Maybe Int
a} :: GetDifferences)

-- | The name of the repository where you want to get differences.
getDifferences_repositoryName :: Lens.Lens' GetDifferences Prelude.Text
getDifferences_repositoryName :: (Text -> f Text) -> GetDifferences -> f GetDifferences
getDifferences_repositoryName = (GetDifferences -> Text)
-> (GetDifferences -> Text -> GetDifferences)
-> Lens GetDifferences GetDifferences Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDifferences' {Text
repositoryName :: Text
$sel:repositoryName:GetDifferences' :: GetDifferences -> Text
repositoryName} -> Text
repositoryName) (\s :: GetDifferences
s@GetDifferences' {} Text
a -> GetDifferences
s {$sel:repositoryName:GetDifferences' :: Text
repositoryName = Text
a} :: GetDifferences)

-- | The branch, tag, HEAD, or other fully qualified reference used to
-- identify a commit.
getDifferences_afterCommitSpecifier :: Lens.Lens' GetDifferences Prelude.Text
getDifferences_afterCommitSpecifier :: (Text -> f Text) -> GetDifferences -> f GetDifferences
getDifferences_afterCommitSpecifier = (GetDifferences -> Text)
-> (GetDifferences -> Text -> GetDifferences)
-> Lens GetDifferences GetDifferences Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDifferences' {Text
afterCommitSpecifier :: Text
$sel:afterCommitSpecifier:GetDifferences' :: GetDifferences -> Text
afterCommitSpecifier} -> Text
afterCommitSpecifier) (\s :: GetDifferences
s@GetDifferences' {} Text
a -> GetDifferences
s {$sel:afterCommitSpecifier:GetDifferences' :: Text
afterCommitSpecifier = Text
a} :: GetDifferences)

instance Core.AWSPager GetDifferences where
  page :: GetDifferences
-> AWSResponse GetDifferences -> Maybe GetDifferences
page GetDifferences
rq AWSResponse GetDifferences
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetDifferences
GetDifferencesResponse
rs
            GetDifferencesResponse
-> Getting (First Text) GetDifferencesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetDifferencesResponse
-> Const (First Text) GetDifferencesResponse
Lens' GetDifferencesResponse (Maybe Text)
getDifferencesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetDifferencesResponse
 -> Const (First Text) GetDifferencesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetDifferencesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetDifferences
forall a. Maybe a
Prelude.Nothing
    | Maybe [Difference] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetDifferences
GetDifferencesResponse
rs
            GetDifferencesResponse
-> Getting (First [Difference]) GetDifferencesResponse [Difference]
-> Maybe [Difference]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Difference]
 -> Const (First [Difference]) (Maybe [Difference]))
-> GetDifferencesResponse
-> Const (First [Difference]) GetDifferencesResponse
Lens' GetDifferencesResponse (Maybe [Difference])
getDifferencesResponse_differences
              ((Maybe [Difference]
  -> Const (First [Difference]) (Maybe [Difference]))
 -> GetDifferencesResponse
 -> Const (First [Difference]) GetDifferencesResponse)
-> (([Difference] -> Const (First [Difference]) [Difference])
    -> Maybe [Difference]
    -> Const (First [Difference]) (Maybe [Difference]))
-> Getting (First [Difference]) GetDifferencesResponse [Difference]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Difference] -> Const (First [Difference]) [Difference])
-> Maybe [Difference]
-> Const (First [Difference]) (Maybe [Difference])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetDifferences
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      GetDifferences -> Maybe GetDifferences
forall a. a -> Maybe a
Prelude.Just (GetDifferences -> Maybe GetDifferences)
-> GetDifferences -> Maybe GetDifferences
forall a b. (a -> b) -> a -> b
Prelude.$
        GetDifferences
rq
          GetDifferences
-> (GetDifferences -> GetDifferences) -> GetDifferences
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetDifferences -> Identity GetDifferences
Lens GetDifferences GetDifferences (Maybe Text) (Maybe Text)
getDifferences_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> GetDifferences -> Identity GetDifferences)
-> Maybe Text -> GetDifferences -> GetDifferences
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetDifferences
GetDifferencesResponse
rs
          GetDifferencesResponse
-> Getting (First Text) GetDifferencesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetDifferencesResponse
-> Const (First Text) GetDifferencesResponse
Lens' GetDifferencesResponse (Maybe Text)
getDifferencesResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetDifferencesResponse
 -> Const (First Text) GetDifferencesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetDifferencesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest GetDifferences where
  type
    AWSResponse GetDifferences =
      GetDifferencesResponse
  request :: GetDifferences -> Request GetDifferences
request = Service -> GetDifferences -> Request GetDifferences
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDifferences
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDifferences)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDifferences))
-> Logger
-> Service
-> Proxy GetDifferences
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDifferences)))
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 Text -> Maybe [Difference] -> Int -> GetDifferencesResponse
GetDifferencesResponse'
            (Maybe Text -> Maybe [Difference] -> Int -> GetDifferencesResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [Difference] -> Int -> GetDifferencesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Maybe [Difference] -> Int -> GetDifferencesResponse)
-> Either String (Maybe [Difference])
-> Either String (Int -> GetDifferencesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Difference]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"differences" Either String (Maybe (Maybe [Difference]))
-> Maybe [Difference] -> Either String (Maybe [Difference])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Difference]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> GetDifferencesResponse)
-> Either String Int -> Either String GetDifferencesResponse
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 GetDifferences

instance Prelude.NFData GetDifferences

instance Core.ToHeaders GetDifferences where
  toHeaders :: GetDifferences -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetDifferences -> 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
"CodeCommit_20150413.GetDifferences" ::
                          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 GetDifferences where
  toJSON :: GetDifferences -> Value
toJSON GetDifferences' {Maybe Int
Maybe Text
Text
afterCommitSpecifier :: Text
repositoryName :: Text
maxResults :: Maybe Int
beforePath :: Maybe Text
beforeCommitSpecifier :: Maybe Text
nextToken :: Maybe Text
afterPath :: Maybe Text
$sel:afterCommitSpecifier:GetDifferences' :: GetDifferences -> Text
$sel:repositoryName:GetDifferences' :: GetDifferences -> Text
$sel:maxResults:GetDifferences' :: GetDifferences -> Maybe Int
$sel:beforePath:GetDifferences' :: GetDifferences -> Maybe Text
$sel:beforeCommitSpecifier:GetDifferences' :: GetDifferences -> Maybe Text
$sel:nextToken:GetDifferences' :: GetDifferences -> Maybe Text
$sel:afterPath:GetDifferences' :: GetDifferences -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"afterPath" 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
afterPath,
            (Text
"NextToken" 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
nextToken,
            (Text
"beforeCommitSpecifier" 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
beforeCommitSpecifier,
            (Text
"beforePath" 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
beforePath,
            (Text
"MaxResults" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"repositoryName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
repositoryName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"afterCommitSpecifier"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
afterCommitSpecifier
              )
          ]
      )

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

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

-- | /See:/ 'newGetDifferencesResponse' smart constructor.
data GetDifferencesResponse = GetDifferencesResponse'
  { -- | An enumeration token that can be used in a request to return the next
    -- batch of the results.
    GetDifferencesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A data type object that contains information about the differences,
    -- including whether the difference is added, modified, or deleted (A, D,
    -- M).
    GetDifferencesResponse -> Maybe [Difference]
differences :: Prelude.Maybe [Difference],
    -- | The response's http status code.
    GetDifferencesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDifferencesResponse -> GetDifferencesResponse -> Bool
(GetDifferencesResponse -> GetDifferencesResponse -> Bool)
-> (GetDifferencesResponse -> GetDifferencesResponse -> Bool)
-> Eq GetDifferencesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDifferencesResponse -> GetDifferencesResponse -> Bool
$c/= :: GetDifferencesResponse -> GetDifferencesResponse -> Bool
== :: GetDifferencesResponse -> GetDifferencesResponse -> Bool
$c== :: GetDifferencesResponse -> GetDifferencesResponse -> Bool
Prelude.Eq, ReadPrec [GetDifferencesResponse]
ReadPrec GetDifferencesResponse
Int -> ReadS GetDifferencesResponse
ReadS [GetDifferencesResponse]
(Int -> ReadS GetDifferencesResponse)
-> ReadS [GetDifferencesResponse]
-> ReadPrec GetDifferencesResponse
-> ReadPrec [GetDifferencesResponse]
-> Read GetDifferencesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDifferencesResponse]
$creadListPrec :: ReadPrec [GetDifferencesResponse]
readPrec :: ReadPrec GetDifferencesResponse
$creadPrec :: ReadPrec GetDifferencesResponse
readList :: ReadS [GetDifferencesResponse]
$creadList :: ReadS [GetDifferencesResponse]
readsPrec :: Int -> ReadS GetDifferencesResponse
$creadsPrec :: Int -> ReadS GetDifferencesResponse
Prelude.Read, Int -> GetDifferencesResponse -> ShowS
[GetDifferencesResponse] -> ShowS
GetDifferencesResponse -> String
(Int -> GetDifferencesResponse -> ShowS)
-> (GetDifferencesResponse -> String)
-> ([GetDifferencesResponse] -> ShowS)
-> Show GetDifferencesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDifferencesResponse] -> ShowS
$cshowList :: [GetDifferencesResponse] -> ShowS
show :: GetDifferencesResponse -> String
$cshow :: GetDifferencesResponse -> String
showsPrec :: Int -> GetDifferencesResponse -> ShowS
$cshowsPrec :: Int -> GetDifferencesResponse -> ShowS
Prelude.Show, (forall x. GetDifferencesResponse -> Rep GetDifferencesResponse x)
-> (forall x.
    Rep GetDifferencesResponse x -> GetDifferencesResponse)
-> Generic GetDifferencesResponse
forall x. Rep GetDifferencesResponse x -> GetDifferencesResponse
forall x. GetDifferencesResponse -> Rep GetDifferencesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDifferencesResponse x -> GetDifferencesResponse
$cfrom :: forall x. GetDifferencesResponse -> Rep GetDifferencesResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDifferencesResponse' 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:
--
-- 'nextToken', 'getDifferencesResponse_nextToken' - An enumeration token that can be used in a request to return the next
-- batch of the results.
--
-- 'differences', 'getDifferencesResponse_differences' - A data type object that contains information about the differences,
-- including whether the difference is added, modified, or deleted (A, D,
-- M).
--
-- 'httpStatus', 'getDifferencesResponse_httpStatus' - The response's http status code.
newGetDifferencesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDifferencesResponse
newGetDifferencesResponse :: Int -> GetDifferencesResponse
newGetDifferencesResponse Int
pHttpStatus_ =
  GetDifferencesResponse' :: Maybe Text -> Maybe [Difference] -> Int -> GetDifferencesResponse
GetDifferencesResponse'
    { $sel:nextToken:GetDifferencesResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:differences:GetDifferencesResponse' :: Maybe [Difference]
differences = Maybe [Difference]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDifferencesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An enumeration token that can be used in a request to return the next
-- batch of the results.
getDifferencesResponse_nextToken :: Lens.Lens' GetDifferencesResponse (Prelude.Maybe Prelude.Text)
getDifferencesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetDifferencesResponse -> f GetDifferencesResponse
getDifferencesResponse_nextToken = (GetDifferencesResponse -> Maybe Text)
-> (GetDifferencesResponse -> Maybe Text -> GetDifferencesResponse)
-> Lens' GetDifferencesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDifferencesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetDifferencesResponse' :: GetDifferencesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetDifferencesResponse
s@GetDifferencesResponse' {} Maybe Text
a -> GetDifferencesResponse
s {$sel:nextToken:GetDifferencesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetDifferencesResponse)

-- | A data type object that contains information about the differences,
-- including whether the difference is added, modified, or deleted (A, D,
-- M).
getDifferencesResponse_differences :: Lens.Lens' GetDifferencesResponse (Prelude.Maybe [Difference])
getDifferencesResponse_differences :: (Maybe [Difference] -> f (Maybe [Difference]))
-> GetDifferencesResponse -> f GetDifferencesResponse
getDifferencesResponse_differences = (GetDifferencesResponse -> Maybe [Difference])
-> (GetDifferencesResponse
    -> Maybe [Difference] -> GetDifferencesResponse)
-> Lens' GetDifferencesResponse (Maybe [Difference])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDifferencesResponse' {Maybe [Difference]
differences :: Maybe [Difference]
$sel:differences:GetDifferencesResponse' :: GetDifferencesResponse -> Maybe [Difference]
differences} -> Maybe [Difference]
differences) (\s :: GetDifferencesResponse
s@GetDifferencesResponse' {} Maybe [Difference]
a -> GetDifferencesResponse
s {$sel:differences:GetDifferencesResponse' :: Maybe [Difference]
differences = Maybe [Difference]
a} :: GetDifferencesResponse) ((Maybe [Difference] -> f (Maybe [Difference]))
 -> GetDifferencesResponse -> f GetDifferencesResponse)
-> ((Maybe [Difference] -> f (Maybe [Difference]))
    -> Maybe [Difference] -> f (Maybe [Difference]))
-> (Maybe [Difference] -> f (Maybe [Difference]))
-> GetDifferencesResponse
-> f GetDifferencesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Difference] [Difference] [Difference] [Difference]
-> Iso
     (Maybe [Difference])
     (Maybe [Difference])
     (Maybe [Difference])
     (Maybe [Difference])
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 [Difference] [Difference] [Difference] [Difference]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetDifferencesResponse