{-# 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.Pinpoint.GetSegmentVersion
-- 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)
--
-- Retrieves information about the configuration, dimension, and other
-- settings for a specific version of a segment that\'s associated with an
-- application.
module Amazonka.Pinpoint.GetSegmentVersion
  ( -- * Creating a Request
    GetSegmentVersion (..),
    newGetSegmentVersion,

    -- * Request Lenses
    getSegmentVersion_segmentId,
    getSegmentVersion_version,
    getSegmentVersion_applicationId,

    -- * Destructuring the Response
    GetSegmentVersionResponse (..),
    newGetSegmentVersionResponse,

    -- * Response Lenses
    getSegmentVersionResponse_httpStatus,
    getSegmentVersionResponse_segmentResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetSegmentVersion' smart constructor.
data GetSegmentVersion = GetSegmentVersion'
  { -- | The unique identifier for the segment.
    GetSegmentVersion -> Text
segmentId :: Prelude.Text,
    -- | The unique version number (Version property) for the campaign version.
    GetSegmentVersion -> Text
version :: Prelude.Text,
    -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    GetSegmentVersion -> Text
applicationId :: Prelude.Text
  }
  deriving (GetSegmentVersion -> GetSegmentVersion -> Bool
(GetSegmentVersion -> GetSegmentVersion -> Bool)
-> (GetSegmentVersion -> GetSegmentVersion -> Bool)
-> Eq GetSegmentVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSegmentVersion -> GetSegmentVersion -> Bool
$c/= :: GetSegmentVersion -> GetSegmentVersion -> Bool
== :: GetSegmentVersion -> GetSegmentVersion -> Bool
$c== :: GetSegmentVersion -> GetSegmentVersion -> Bool
Prelude.Eq, ReadPrec [GetSegmentVersion]
ReadPrec GetSegmentVersion
Int -> ReadS GetSegmentVersion
ReadS [GetSegmentVersion]
(Int -> ReadS GetSegmentVersion)
-> ReadS [GetSegmentVersion]
-> ReadPrec GetSegmentVersion
-> ReadPrec [GetSegmentVersion]
-> Read GetSegmentVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSegmentVersion]
$creadListPrec :: ReadPrec [GetSegmentVersion]
readPrec :: ReadPrec GetSegmentVersion
$creadPrec :: ReadPrec GetSegmentVersion
readList :: ReadS [GetSegmentVersion]
$creadList :: ReadS [GetSegmentVersion]
readsPrec :: Int -> ReadS GetSegmentVersion
$creadsPrec :: Int -> ReadS GetSegmentVersion
Prelude.Read, Int -> GetSegmentVersion -> ShowS
[GetSegmentVersion] -> ShowS
GetSegmentVersion -> String
(Int -> GetSegmentVersion -> ShowS)
-> (GetSegmentVersion -> String)
-> ([GetSegmentVersion] -> ShowS)
-> Show GetSegmentVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSegmentVersion] -> ShowS
$cshowList :: [GetSegmentVersion] -> ShowS
show :: GetSegmentVersion -> String
$cshow :: GetSegmentVersion -> String
showsPrec :: Int -> GetSegmentVersion -> ShowS
$cshowsPrec :: Int -> GetSegmentVersion -> ShowS
Prelude.Show, (forall x. GetSegmentVersion -> Rep GetSegmentVersion x)
-> (forall x. Rep GetSegmentVersion x -> GetSegmentVersion)
-> Generic GetSegmentVersion
forall x. Rep GetSegmentVersion x -> GetSegmentVersion
forall x. GetSegmentVersion -> Rep GetSegmentVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSegmentVersion x -> GetSegmentVersion
$cfrom :: forall x. GetSegmentVersion -> Rep GetSegmentVersion x
Prelude.Generic)

-- |
-- Create a value of 'GetSegmentVersion' 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:
--
-- 'segmentId', 'getSegmentVersion_segmentId' - The unique identifier for the segment.
--
-- 'version', 'getSegmentVersion_version' - The unique version number (Version property) for the campaign version.
--
-- 'applicationId', 'getSegmentVersion_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
newGetSegmentVersion ::
  -- | 'segmentId'
  Prelude.Text ->
  -- | 'version'
  Prelude.Text ->
  -- | 'applicationId'
  Prelude.Text ->
  GetSegmentVersion
newGetSegmentVersion :: Text -> Text -> Text -> GetSegmentVersion
newGetSegmentVersion
  Text
pSegmentId_
  Text
pVersion_
  Text
pApplicationId_ =
    GetSegmentVersion' :: Text -> Text -> Text -> GetSegmentVersion
GetSegmentVersion'
      { $sel:segmentId:GetSegmentVersion' :: Text
segmentId = Text
pSegmentId_,
        $sel:version:GetSegmentVersion' :: Text
version = Text
pVersion_,
        $sel:applicationId:GetSegmentVersion' :: Text
applicationId = Text
pApplicationId_
      }

-- | The unique identifier for the segment.
getSegmentVersion_segmentId :: Lens.Lens' GetSegmentVersion Prelude.Text
getSegmentVersion_segmentId :: (Text -> f Text) -> GetSegmentVersion -> f GetSegmentVersion
getSegmentVersion_segmentId = (GetSegmentVersion -> Text)
-> (GetSegmentVersion -> Text -> GetSegmentVersion)
-> Lens GetSegmentVersion GetSegmentVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSegmentVersion' {Text
segmentId :: Text
$sel:segmentId:GetSegmentVersion' :: GetSegmentVersion -> Text
segmentId} -> Text
segmentId) (\s :: GetSegmentVersion
s@GetSegmentVersion' {} Text
a -> GetSegmentVersion
s {$sel:segmentId:GetSegmentVersion' :: Text
segmentId = Text
a} :: GetSegmentVersion)

-- | The unique version number (Version property) for the campaign version.
getSegmentVersion_version :: Lens.Lens' GetSegmentVersion Prelude.Text
getSegmentVersion_version :: (Text -> f Text) -> GetSegmentVersion -> f GetSegmentVersion
getSegmentVersion_version = (GetSegmentVersion -> Text)
-> (GetSegmentVersion -> Text -> GetSegmentVersion)
-> Lens GetSegmentVersion GetSegmentVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSegmentVersion' {Text
version :: Text
$sel:version:GetSegmentVersion' :: GetSegmentVersion -> Text
version} -> Text
version) (\s :: GetSegmentVersion
s@GetSegmentVersion' {} Text
a -> GetSegmentVersion
s {$sel:version:GetSegmentVersion' :: Text
version = Text
a} :: GetSegmentVersion)

-- | The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
getSegmentVersion_applicationId :: Lens.Lens' GetSegmentVersion Prelude.Text
getSegmentVersion_applicationId :: (Text -> f Text) -> GetSegmentVersion -> f GetSegmentVersion
getSegmentVersion_applicationId = (GetSegmentVersion -> Text)
-> (GetSegmentVersion -> Text -> GetSegmentVersion)
-> Lens GetSegmentVersion GetSegmentVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSegmentVersion' {Text
applicationId :: Text
$sel:applicationId:GetSegmentVersion' :: GetSegmentVersion -> Text
applicationId} -> Text
applicationId) (\s :: GetSegmentVersion
s@GetSegmentVersion' {} Text
a -> GetSegmentVersion
s {$sel:applicationId:GetSegmentVersion' :: Text
applicationId = Text
a} :: GetSegmentVersion)

instance Core.AWSRequest GetSegmentVersion where
  type
    AWSResponse GetSegmentVersion =
      GetSegmentVersionResponse
  request :: GetSegmentVersion -> Request GetSegmentVersion
request = Service -> GetSegmentVersion -> Request GetSegmentVersion
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetSegmentVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetSegmentVersion)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetSegmentVersion))
-> Logger
-> Service
-> Proxy GetSegmentVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetSegmentVersion)))
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 ->
          Int -> SegmentResponse -> GetSegmentVersionResponse
GetSegmentVersionResponse'
            (Int -> SegmentResponse -> GetSegmentVersionResponse)
-> Either String Int
-> Either String (SegmentResponse -> GetSegmentVersionResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (SegmentResponse -> GetSegmentVersionResponse)
-> Either String SegmentResponse
-> Either String GetSegmentVersionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String SegmentResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable GetSegmentVersion

instance Prelude.NFData GetSegmentVersion

instance Core.ToHeaders GetSegmentVersion where
  toHeaders :: GetSegmentVersion -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetSegmentVersion -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath GetSegmentVersion where
  toPath :: GetSegmentVersion -> ByteString
toPath GetSegmentVersion' {Text
applicationId :: Text
version :: Text
segmentId :: Text
$sel:applicationId:GetSegmentVersion' :: GetSegmentVersion -> Text
$sel:version:GetSegmentVersion' :: GetSegmentVersion -> Text
$sel:segmentId:GetSegmentVersion' :: GetSegmentVersion -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/apps/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId,
        ByteString
"/segments/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
segmentId,
        ByteString
"/versions/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
version
      ]

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

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

-- |
-- Create a value of 'GetSegmentVersionResponse' 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:
--
-- 'httpStatus', 'getSegmentVersionResponse_httpStatus' - The response's http status code.
--
-- 'segmentResponse', 'getSegmentVersionResponse_segmentResponse' - Undocumented member.
newGetSegmentVersionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'segmentResponse'
  SegmentResponse ->
  GetSegmentVersionResponse
newGetSegmentVersionResponse :: Int -> SegmentResponse -> GetSegmentVersionResponse
newGetSegmentVersionResponse
  Int
pHttpStatus_
  SegmentResponse
pSegmentResponse_ =
    GetSegmentVersionResponse' :: Int -> SegmentResponse -> GetSegmentVersionResponse
GetSegmentVersionResponse'
      { $sel:httpStatus:GetSegmentVersionResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:segmentResponse:GetSegmentVersionResponse' :: SegmentResponse
segmentResponse = SegmentResponse
pSegmentResponse_
      }

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

-- | Undocumented member.
getSegmentVersionResponse_segmentResponse :: Lens.Lens' GetSegmentVersionResponse SegmentResponse
getSegmentVersionResponse_segmentResponse :: (SegmentResponse -> f SegmentResponse)
-> GetSegmentVersionResponse -> f GetSegmentVersionResponse
getSegmentVersionResponse_segmentResponse = (GetSegmentVersionResponse -> SegmentResponse)
-> (GetSegmentVersionResponse
    -> SegmentResponse -> GetSegmentVersionResponse)
-> Lens
     GetSegmentVersionResponse
     GetSegmentVersionResponse
     SegmentResponse
     SegmentResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSegmentVersionResponse' {SegmentResponse
segmentResponse :: SegmentResponse
$sel:segmentResponse:GetSegmentVersionResponse' :: GetSegmentVersionResponse -> SegmentResponse
segmentResponse} -> SegmentResponse
segmentResponse) (\s :: GetSegmentVersionResponse
s@GetSegmentVersionResponse' {} SegmentResponse
a -> GetSegmentVersionResponse
s {$sel:segmentResponse:GetSegmentVersionResponse' :: SegmentResponse
segmentResponse = SegmentResponse
a} :: GetSegmentVersionResponse)

instance Prelude.NFData GetSegmentVersionResponse