{-# 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.SSM.GetParametersByPath
-- 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)
--
-- Retrieve information about one or more parameters in a specific
-- hierarchy.
--
-- Request results are returned on a best-effort basis. If you specify
-- @MaxResults@ in the request, the response includes information up to the
-- limit specified. The number of items returned, however, can be between
-- zero and the value of @MaxResults@. If the service reaches an internal
-- limit while processing the results, it stops the operation and returns
-- the matching values up to that point and a @NextToken@. You can specify
-- the @NextToken@ in a subsequent call to get the next set of results.
--
-- This operation returns paginated results.
module Amazonka.SSM.GetParametersByPath
  ( -- * Creating a Request
    GetParametersByPath (..),
    newGetParametersByPath,

    -- * Request Lenses
    getParametersByPath_withDecryption,
    getParametersByPath_parameterFilters,
    getParametersByPath_nextToken,
    getParametersByPath_recursive,
    getParametersByPath_maxResults,
    getParametersByPath_path,

    -- * Destructuring the Response
    GetParametersByPathResponse (..),
    newGetParametersByPathResponse,

    -- * Response Lenses
    getParametersByPathResponse_nextToken,
    getParametersByPathResponse_parameters,
    getParametersByPathResponse_httpStatus,
  )
where

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
import Amazonka.SSM.Types

-- | /See:/ 'newGetParametersByPath' smart constructor.
data GetParametersByPath = GetParametersByPath'
  { -- | Retrieve all parameters in a hierarchy with their value decrypted.
    GetParametersByPath -> Maybe Bool
withDecryption :: Prelude.Maybe Prelude.Bool,
    -- | Filters to limit the request results.
    --
    -- The following @Key@ values are supported for @GetParametersByPath@:
    -- @Type@, @KeyId@, and @Label@.
    --
    -- The following @Key@ values aren\'t supported for @GetParametersByPath@:
    -- @tag@, @DataType@, @Name@, @Path@, and @Tier@.
    GetParametersByPath -> Maybe [ParameterStringFilter]
parameterFilters :: Prelude.Maybe [ParameterStringFilter],
    -- | A token to start the list. Use this token to get the next set of
    -- results.
    GetParametersByPath -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Retrieve all parameters within a hierarchy.
    --
    -- If a user has access to a path, then the user can access all levels of
    -- that path. For example, if a user has permission to access path @\/a@,
    -- then the user can also access @\/a\/b@. Even if a user has explicitly
    -- been denied access in IAM for parameter @\/a\/b@, they can still call
    -- the GetParametersByPath API operation recursively for @\/a@ and view
    -- @\/a\/b@.
    GetParametersByPath -> Maybe Bool
recursive :: Prelude.Maybe Prelude.Bool,
    -- | The maximum number of items to return for this call. The call also
    -- returns a token that you can specify in a subsequent call to get the
    -- next set of results.
    GetParametersByPath -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The hierarchy for the parameter. Hierarchies start with a forward slash
    -- (\/). The hierachy is the parameter name except the last part of the
    -- parameter. For the API call to succeeed, the last part of the parameter
    -- name can\'t be in the path. A parameter name hierarchy can have a
    -- maximum of 15 levels. Here is an example of a hierarchy:
    -- @\/Finance\/Prod\/IAD\/WinServ2016\/license33 @
    GetParametersByPath -> Text
path :: Prelude.Text
  }
  deriving (GetParametersByPath -> GetParametersByPath -> Bool
(GetParametersByPath -> GetParametersByPath -> Bool)
-> (GetParametersByPath -> GetParametersByPath -> Bool)
-> Eq GetParametersByPath
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetParametersByPath -> GetParametersByPath -> Bool
$c/= :: GetParametersByPath -> GetParametersByPath -> Bool
== :: GetParametersByPath -> GetParametersByPath -> Bool
$c== :: GetParametersByPath -> GetParametersByPath -> Bool
Prelude.Eq, ReadPrec [GetParametersByPath]
ReadPrec GetParametersByPath
Int -> ReadS GetParametersByPath
ReadS [GetParametersByPath]
(Int -> ReadS GetParametersByPath)
-> ReadS [GetParametersByPath]
-> ReadPrec GetParametersByPath
-> ReadPrec [GetParametersByPath]
-> Read GetParametersByPath
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetParametersByPath]
$creadListPrec :: ReadPrec [GetParametersByPath]
readPrec :: ReadPrec GetParametersByPath
$creadPrec :: ReadPrec GetParametersByPath
readList :: ReadS [GetParametersByPath]
$creadList :: ReadS [GetParametersByPath]
readsPrec :: Int -> ReadS GetParametersByPath
$creadsPrec :: Int -> ReadS GetParametersByPath
Prelude.Read, Int -> GetParametersByPath -> ShowS
[GetParametersByPath] -> ShowS
GetParametersByPath -> String
(Int -> GetParametersByPath -> ShowS)
-> (GetParametersByPath -> String)
-> ([GetParametersByPath] -> ShowS)
-> Show GetParametersByPath
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetParametersByPath] -> ShowS
$cshowList :: [GetParametersByPath] -> ShowS
show :: GetParametersByPath -> String
$cshow :: GetParametersByPath -> String
showsPrec :: Int -> GetParametersByPath -> ShowS
$cshowsPrec :: Int -> GetParametersByPath -> ShowS
Prelude.Show, (forall x. GetParametersByPath -> Rep GetParametersByPath x)
-> (forall x. Rep GetParametersByPath x -> GetParametersByPath)
-> Generic GetParametersByPath
forall x. Rep GetParametersByPath x -> GetParametersByPath
forall x. GetParametersByPath -> Rep GetParametersByPath x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetParametersByPath x -> GetParametersByPath
$cfrom :: forall x. GetParametersByPath -> Rep GetParametersByPath x
Prelude.Generic)

-- |
-- Create a value of 'GetParametersByPath' 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:
--
-- 'withDecryption', 'getParametersByPath_withDecryption' - Retrieve all parameters in a hierarchy with their value decrypted.
--
-- 'parameterFilters', 'getParametersByPath_parameterFilters' - Filters to limit the request results.
--
-- The following @Key@ values are supported for @GetParametersByPath@:
-- @Type@, @KeyId@, and @Label@.
--
-- The following @Key@ values aren\'t supported for @GetParametersByPath@:
-- @tag@, @DataType@, @Name@, @Path@, and @Tier@.
--
-- 'nextToken', 'getParametersByPath_nextToken' - A token to start the list. Use this token to get the next set of
-- results.
--
-- 'recursive', 'getParametersByPath_recursive' - Retrieve all parameters within a hierarchy.
--
-- If a user has access to a path, then the user can access all levels of
-- that path. For example, if a user has permission to access path @\/a@,
-- then the user can also access @\/a\/b@. Even if a user has explicitly
-- been denied access in IAM for parameter @\/a\/b@, they can still call
-- the GetParametersByPath API operation recursively for @\/a@ and view
-- @\/a\/b@.
--
-- 'maxResults', 'getParametersByPath_maxResults' - The maximum number of items to return for this call. The call also
-- returns a token that you can specify in a subsequent call to get the
-- next set of results.
--
-- 'path', 'getParametersByPath_path' - The hierarchy for the parameter. Hierarchies start with a forward slash
-- (\/). The hierachy is the parameter name except the last part of the
-- parameter. For the API call to succeeed, the last part of the parameter
-- name can\'t be in the path. A parameter name hierarchy can have a
-- maximum of 15 levels. Here is an example of a hierarchy:
-- @\/Finance\/Prod\/IAD\/WinServ2016\/license33 @
newGetParametersByPath ::
  -- | 'path'
  Prelude.Text ->
  GetParametersByPath
newGetParametersByPath :: Text -> GetParametersByPath
newGetParametersByPath Text
pPath_ =
  GetParametersByPath' :: Maybe Bool
-> Maybe [ParameterStringFilter]
-> Maybe Text
-> Maybe Bool
-> Maybe Natural
-> Text
-> GetParametersByPath
GetParametersByPath'
    { $sel:withDecryption:GetParametersByPath' :: Maybe Bool
withDecryption =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:parameterFilters:GetParametersByPath' :: Maybe [ParameterStringFilter]
parameterFilters = Maybe [ParameterStringFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetParametersByPath' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:recursive:GetParametersByPath' :: Maybe Bool
recursive = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetParametersByPath' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:path:GetParametersByPath' :: Text
path = Text
pPath_
    }

-- | Retrieve all parameters in a hierarchy with their value decrypted.
getParametersByPath_withDecryption :: Lens.Lens' GetParametersByPath (Prelude.Maybe Prelude.Bool)
getParametersByPath_withDecryption :: (Maybe Bool -> f (Maybe Bool))
-> GetParametersByPath -> f GetParametersByPath
getParametersByPath_withDecryption = (GetParametersByPath -> Maybe Bool)
-> (GetParametersByPath -> Maybe Bool -> GetParametersByPath)
-> Lens
     GetParametersByPath GetParametersByPath (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersByPath' {Maybe Bool
withDecryption :: Maybe Bool
$sel:withDecryption:GetParametersByPath' :: GetParametersByPath -> Maybe Bool
withDecryption} -> Maybe Bool
withDecryption) (\s :: GetParametersByPath
s@GetParametersByPath' {} Maybe Bool
a -> GetParametersByPath
s {$sel:withDecryption:GetParametersByPath' :: Maybe Bool
withDecryption = Maybe Bool
a} :: GetParametersByPath)

-- | Filters to limit the request results.
--
-- The following @Key@ values are supported for @GetParametersByPath@:
-- @Type@, @KeyId@, and @Label@.
--
-- The following @Key@ values aren\'t supported for @GetParametersByPath@:
-- @tag@, @DataType@, @Name@, @Path@, and @Tier@.
getParametersByPath_parameterFilters :: Lens.Lens' GetParametersByPath (Prelude.Maybe [ParameterStringFilter])
getParametersByPath_parameterFilters :: (Maybe [ParameterStringFilter]
 -> f (Maybe [ParameterStringFilter]))
-> GetParametersByPath -> f GetParametersByPath
getParametersByPath_parameterFilters = (GetParametersByPath -> Maybe [ParameterStringFilter])
-> (GetParametersByPath
    -> Maybe [ParameterStringFilter] -> GetParametersByPath)
-> Lens
     GetParametersByPath
     GetParametersByPath
     (Maybe [ParameterStringFilter])
     (Maybe [ParameterStringFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersByPath' {Maybe [ParameterStringFilter]
parameterFilters :: Maybe [ParameterStringFilter]
$sel:parameterFilters:GetParametersByPath' :: GetParametersByPath -> Maybe [ParameterStringFilter]
parameterFilters} -> Maybe [ParameterStringFilter]
parameterFilters) (\s :: GetParametersByPath
s@GetParametersByPath' {} Maybe [ParameterStringFilter]
a -> GetParametersByPath
s {$sel:parameterFilters:GetParametersByPath' :: Maybe [ParameterStringFilter]
parameterFilters = Maybe [ParameterStringFilter]
a} :: GetParametersByPath) ((Maybe [ParameterStringFilter]
  -> f (Maybe [ParameterStringFilter]))
 -> GetParametersByPath -> f GetParametersByPath)
-> ((Maybe [ParameterStringFilter]
     -> f (Maybe [ParameterStringFilter]))
    -> Maybe [ParameterStringFilter]
    -> f (Maybe [ParameterStringFilter]))
-> (Maybe [ParameterStringFilter]
    -> f (Maybe [ParameterStringFilter]))
-> GetParametersByPath
-> f GetParametersByPath
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ParameterStringFilter]
  [ParameterStringFilter]
  [ParameterStringFilter]
  [ParameterStringFilter]
-> Iso
     (Maybe [ParameterStringFilter])
     (Maybe [ParameterStringFilter])
     (Maybe [ParameterStringFilter])
     (Maybe [ParameterStringFilter])
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
  [ParameterStringFilter]
  [ParameterStringFilter]
  [ParameterStringFilter]
  [ParameterStringFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A token to start the list. Use this token to get the next set of
-- results.
getParametersByPath_nextToken :: Lens.Lens' GetParametersByPath (Prelude.Maybe Prelude.Text)
getParametersByPath_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetParametersByPath -> f GetParametersByPath
getParametersByPath_nextToken = (GetParametersByPath -> Maybe Text)
-> (GetParametersByPath -> Maybe Text -> GetParametersByPath)
-> Lens
     GetParametersByPath GetParametersByPath (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersByPath' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetParametersByPath' :: GetParametersByPath -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetParametersByPath
s@GetParametersByPath' {} Maybe Text
a -> GetParametersByPath
s {$sel:nextToken:GetParametersByPath' :: Maybe Text
nextToken = Maybe Text
a} :: GetParametersByPath)

-- | Retrieve all parameters within a hierarchy.
--
-- If a user has access to a path, then the user can access all levels of
-- that path. For example, if a user has permission to access path @\/a@,
-- then the user can also access @\/a\/b@. Even if a user has explicitly
-- been denied access in IAM for parameter @\/a\/b@, they can still call
-- the GetParametersByPath API operation recursively for @\/a@ and view
-- @\/a\/b@.
getParametersByPath_recursive :: Lens.Lens' GetParametersByPath (Prelude.Maybe Prelude.Bool)
getParametersByPath_recursive :: (Maybe Bool -> f (Maybe Bool))
-> GetParametersByPath -> f GetParametersByPath
getParametersByPath_recursive = (GetParametersByPath -> Maybe Bool)
-> (GetParametersByPath -> Maybe Bool -> GetParametersByPath)
-> Lens
     GetParametersByPath GetParametersByPath (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersByPath' {Maybe Bool
recursive :: Maybe Bool
$sel:recursive:GetParametersByPath' :: GetParametersByPath -> Maybe Bool
recursive} -> Maybe Bool
recursive) (\s :: GetParametersByPath
s@GetParametersByPath' {} Maybe Bool
a -> GetParametersByPath
s {$sel:recursive:GetParametersByPath' :: Maybe Bool
recursive = Maybe Bool
a} :: GetParametersByPath)

-- | The maximum number of items to return for this call. The call also
-- returns a token that you can specify in a subsequent call to get the
-- next set of results.
getParametersByPath_maxResults :: Lens.Lens' GetParametersByPath (Prelude.Maybe Prelude.Natural)
getParametersByPath_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> GetParametersByPath -> f GetParametersByPath
getParametersByPath_maxResults = (GetParametersByPath -> Maybe Natural)
-> (GetParametersByPath -> Maybe Natural -> GetParametersByPath)
-> Lens
     GetParametersByPath
     GetParametersByPath
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersByPath' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetParametersByPath' :: GetParametersByPath -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetParametersByPath
s@GetParametersByPath' {} Maybe Natural
a -> GetParametersByPath
s {$sel:maxResults:GetParametersByPath' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetParametersByPath)

-- | The hierarchy for the parameter. Hierarchies start with a forward slash
-- (\/). The hierachy is the parameter name except the last part of the
-- parameter. For the API call to succeeed, the last part of the parameter
-- name can\'t be in the path. A parameter name hierarchy can have a
-- maximum of 15 levels. Here is an example of a hierarchy:
-- @\/Finance\/Prod\/IAD\/WinServ2016\/license33 @
getParametersByPath_path :: Lens.Lens' GetParametersByPath Prelude.Text
getParametersByPath_path :: (Text -> f Text) -> GetParametersByPath -> f GetParametersByPath
getParametersByPath_path = (GetParametersByPath -> Text)
-> (GetParametersByPath -> Text -> GetParametersByPath)
-> Lens GetParametersByPath GetParametersByPath Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersByPath' {Text
path :: Text
$sel:path:GetParametersByPath' :: GetParametersByPath -> Text
path} -> Text
path) (\s :: GetParametersByPath
s@GetParametersByPath' {} Text
a -> GetParametersByPath
s {$sel:path:GetParametersByPath' :: Text
path = Text
a} :: GetParametersByPath)

instance Core.AWSPager GetParametersByPath where
  page :: GetParametersByPath
-> AWSResponse GetParametersByPath -> Maybe GetParametersByPath
page GetParametersByPath
rq AWSResponse GetParametersByPath
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetParametersByPath
GetParametersByPathResponse
rs
            GetParametersByPathResponse
-> Getting (First Text) GetParametersByPathResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetParametersByPathResponse
-> Const (First Text) GetParametersByPathResponse
Lens' GetParametersByPathResponse (Maybe Text)
getParametersByPathResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetParametersByPathResponse
 -> Const (First Text) GetParametersByPathResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetParametersByPathResponse 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 GetParametersByPath
forall a. Maybe a
Prelude.Nothing
    | Maybe [Parameter] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetParametersByPath
GetParametersByPathResponse
rs
            GetParametersByPathResponse
-> Getting
     (First [Parameter]) GetParametersByPathResponse [Parameter]
-> Maybe [Parameter]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Parameter]
 -> Const (First [Parameter]) (Maybe [Parameter]))
-> GetParametersByPathResponse
-> Const (First [Parameter]) GetParametersByPathResponse
Lens' GetParametersByPathResponse (Maybe [Parameter])
getParametersByPathResponse_parameters
              ((Maybe [Parameter]
  -> Const (First [Parameter]) (Maybe [Parameter]))
 -> GetParametersByPathResponse
 -> Const (First [Parameter]) GetParametersByPathResponse)
-> (([Parameter] -> Const (First [Parameter]) [Parameter])
    -> Maybe [Parameter]
    -> Const (First [Parameter]) (Maybe [Parameter]))
-> Getting
     (First [Parameter]) GetParametersByPathResponse [Parameter]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Parameter] -> Const (First [Parameter]) [Parameter])
-> Maybe [Parameter]
-> Const (First [Parameter]) (Maybe [Parameter])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetParametersByPath
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      GetParametersByPath -> Maybe GetParametersByPath
forall a. a -> Maybe a
Prelude.Just (GetParametersByPath -> Maybe GetParametersByPath)
-> GetParametersByPath -> Maybe GetParametersByPath
forall a b. (a -> b) -> a -> b
Prelude.$
        GetParametersByPath
rq
          GetParametersByPath
-> (GetParametersByPath -> GetParametersByPath)
-> GetParametersByPath
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetParametersByPath -> Identity GetParametersByPath
Lens
  GetParametersByPath GetParametersByPath (Maybe Text) (Maybe Text)
getParametersByPath_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> GetParametersByPath -> Identity GetParametersByPath)
-> Maybe Text -> GetParametersByPath -> GetParametersByPath
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetParametersByPath
GetParametersByPathResponse
rs
          GetParametersByPathResponse
-> Getting (First Text) GetParametersByPathResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetParametersByPathResponse
-> Const (First Text) GetParametersByPathResponse
Lens' GetParametersByPathResponse (Maybe Text)
getParametersByPathResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetParametersByPathResponse
 -> Const (First Text) GetParametersByPathResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetParametersByPathResponse 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 GetParametersByPath where
  type
    AWSResponse GetParametersByPath =
      GetParametersByPathResponse
  request :: GetParametersByPath -> Request GetParametersByPath
request = Service -> GetParametersByPath -> Request GetParametersByPath
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetParametersByPath
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetParametersByPath)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetParametersByPath))
-> Logger
-> Service
-> Proxy GetParametersByPath
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetParametersByPath)))
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 [Parameter] -> Int -> GetParametersByPathResponse
GetParametersByPathResponse'
            (Maybe Text
 -> Maybe [Parameter] -> Int -> GetParametersByPathResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [Parameter] -> Int -> GetParametersByPathResponse)
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 [Parameter] -> Int -> GetParametersByPathResponse)
-> Either String (Maybe [Parameter])
-> Either String (Int -> GetParametersByPathResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Parameter]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Parameters" Either String (Maybe (Maybe [Parameter]))
-> Maybe [Parameter] -> Either String (Maybe [Parameter])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Parameter]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> GetParametersByPathResponse)
-> Either String Int -> Either String GetParametersByPathResponse
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 GetParametersByPath

instance Prelude.NFData GetParametersByPath

instance Core.ToHeaders GetParametersByPath where
  toHeaders :: GetParametersByPath -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetParametersByPath -> 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
"AmazonSSM.GetParametersByPath" ::
                          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 GetParametersByPath where
  toJSON :: GetParametersByPath -> Value
toJSON GetParametersByPath' {Maybe Bool
Maybe Natural
Maybe [ParameterStringFilter]
Maybe Text
Text
path :: Text
maxResults :: Maybe Natural
recursive :: Maybe Bool
nextToken :: Maybe Text
parameterFilters :: Maybe [ParameterStringFilter]
withDecryption :: Maybe Bool
$sel:path:GetParametersByPath' :: GetParametersByPath -> Text
$sel:maxResults:GetParametersByPath' :: GetParametersByPath -> Maybe Natural
$sel:recursive:GetParametersByPath' :: GetParametersByPath -> Maybe Bool
$sel:nextToken:GetParametersByPath' :: GetParametersByPath -> Maybe Text
$sel:parameterFilters:GetParametersByPath' :: GetParametersByPath -> Maybe [ParameterStringFilter]
$sel:withDecryption:GetParametersByPath' :: GetParametersByPath -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"WithDecryption" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
withDecryption,
            (Text
"ParameterFilters" Text -> [ParameterStringFilter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ParameterStringFilter] -> Pair)
-> Maybe [ParameterStringFilter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ParameterStringFilter]
parameterFilters,
            (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
"Recursive" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
recursive,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Path" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
path)
          ]
      )

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

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

-- | /See:/ 'newGetParametersByPathResponse' smart constructor.
data GetParametersByPathResponse = GetParametersByPathResponse'
  { -- | The token for the next set of items to return. Use this token to get the
    -- next set of results.
    GetParametersByPathResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of parameters found in the specified hierarchy.
    GetParametersByPathResponse -> Maybe [Parameter]
parameters :: Prelude.Maybe [Parameter],
    -- | The response's http status code.
    GetParametersByPathResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetParametersByPathResponse -> GetParametersByPathResponse -> Bool
(GetParametersByPathResponse
 -> GetParametersByPathResponse -> Bool)
-> (GetParametersByPathResponse
    -> GetParametersByPathResponse -> Bool)
-> Eq GetParametersByPathResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetParametersByPathResponse -> GetParametersByPathResponse -> Bool
$c/= :: GetParametersByPathResponse -> GetParametersByPathResponse -> Bool
== :: GetParametersByPathResponse -> GetParametersByPathResponse -> Bool
$c== :: GetParametersByPathResponse -> GetParametersByPathResponse -> Bool
Prelude.Eq, Int -> GetParametersByPathResponse -> ShowS
[GetParametersByPathResponse] -> ShowS
GetParametersByPathResponse -> String
(Int -> GetParametersByPathResponse -> ShowS)
-> (GetParametersByPathResponse -> String)
-> ([GetParametersByPathResponse] -> ShowS)
-> Show GetParametersByPathResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetParametersByPathResponse] -> ShowS
$cshowList :: [GetParametersByPathResponse] -> ShowS
show :: GetParametersByPathResponse -> String
$cshow :: GetParametersByPathResponse -> String
showsPrec :: Int -> GetParametersByPathResponse -> ShowS
$cshowsPrec :: Int -> GetParametersByPathResponse -> ShowS
Prelude.Show, (forall x.
 GetParametersByPathResponse -> Rep GetParametersByPathResponse x)
-> (forall x.
    Rep GetParametersByPathResponse x -> GetParametersByPathResponse)
-> Generic GetParametersByPathResponse
forall x.
Rep GetParametersByPathResponse x -> GetParametersByPathResponse
forall x.
GetParametersByPathResponse -> Rep GetParametersByPathResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetParametersByPathResponse x -> GetParametersByPathResponse
$cfrom :: forall x.
GetParametersByPathResponse -> Rep GetParametersByPathResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetParametersByPathResponse' 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', 'getParametersByPathResponse_nextToken' - The token for the next set of items to return. Use this token to get the
-- next set of results.
--
-- 'parameters', 'getParametersByPathResponse_parameters' - A list of parameters found in the specified hierarchy.
--
-- 'httpStatus', 'getParametersByPathResponse_httpStatus' - The response's http status code.
newGetParametersByPathResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetParametersByPathResponse
newGetParametersByPathResponse :: Int -> GetParametersByPathResponse
newGetParametersByPathResponse Int
pHttpStatus_ =
  GetParametersByPathResponse' :: Maybe Text
-> Maybe [Parameter] -> Int -> GetParametersByPathResponse
GetParametersByPathResponse'
    { $sel:nextToken:GetParametersByPathResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:GetParametersByPathResponse' :: Maybe [Parameter]
parameters = Maybe [Parameter]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetParametersByPathResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token for the next set of items to return. Use this token to get the
-- next set of results.
getParametersByPathResponse_nextToken :: Lens.Lens' GetParametersByPathResponse (Prelude.Maybe Prelude.Text)
getParametersByPathResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetParametersByPathResponse -> f GetParametersByPathResponse
getParametersByPathResponse_nextToken = (GetParametersByPathResponse -> Maybe Text)
-> (GetParametersByPathResponse
    -> Maybe Text -> GetParametersByPathResponse)
-> Lens' GetParametersByPathResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersByPathResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetParametersByPathResponse' :: GetParametersByPathResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetParametersByPathResponse
s@GetParametersByPathResponse' {} Maybe Text
a -> GetParametersByPathResponse
s {$sel:nextToken:GetParametersByPathResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetParametersByPathResponse)

-- | A list of parameters found in the specified hierarchy.
getParametersByPathResponse_parameters :: Lens.Lens' GetParametersByPathResponse (Prelude.Maybe [Parameter])
getParametersByPathResponse_parameters :: (Maybe [Parameter] -> f (Maybe [Parameter]))
-> GetParametersByPathResponse -> f GetParametersByPathResponse
getParametersByPathResponse_parameters = (GetParametersByPathResponse -> Maybe [Parameter])
-> (GetParametersByPathResponse
    -> Maybe [Parameter] -> GetParametersByPathResponse)
-> Lens' GetParametersByPathResponse (Maybe [Parameter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersByPathResponse' {Maybe [Parameter]
parameters :: Maybe [Parameter]
$sel:parameters:GetParametersByPathResponse' :: GetParametersByPathResponse -> Maybe [Parameter]
parameters} -> Maybe [Parameter]
parameters) (\s :: GetParametersByPathResponse
s@GetParametersByPathResponse' {} Maybe [Parameter]
a -> GetParametersByPathResponse
s {$sel:parameters:GetParametersByPathResponse' :: Maybe [Parameter]
parameters = Maybe [Parameter]
a} :: GetParametersByPathResponse) ((Maybe [Parameter] -> f (Maybe [Parameter]))
 -> GetParametersByPathResponse -> f GetParametersByPathResponse)
-> ((Maybe [Parameter] -> f (Maybe [Parameter]))
    -> Maybe [Parameter] -> f (Maybe [Parameter]))
-> (Maybe [Parameter] -> f (Maybe [Parameter]))
-> GetParametersByPathResponse
-> f GetParametersByPathResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Parameter] [Parameter] [Parameter] [Parameter]
-> Iso
     (Maybe [Parameter])
     (Maybe [Parameter])
     (Maybe [Parameter])
     (Maybe [Parameter])
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 [Parameter] [Parameter] [Parameter] [Parameter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetParametersByPathResponse