{-# 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.CustomerProfiles.SearchProfiles
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Searches for profiles within a specific domain using one or more
-- predefined search keys (e.g., _fullName, _phone, _email, _account, etc.)
-- and\/or custom-defined search keys. A search key is a data type pair
-- that consists of a @KeyName@ and @Values@ list.
--
-- This operation supports searching for profiles with a minimum of 1
-- key-value(s) pair and up to 5 key-value(s) pairs using either @AND@ or
-- @OR@ logic.
module Amazonka.CustomerProfiles.SearchProfiles
  ( -- * Creating a Request
    SearchProfiles (..),
    newSearchProfiles,

    -- * Request Lenses
    searchProfiles_additionalSearchKeys,
    searchProfiles_logicalOperator,
    searchProfiles_maxResults,
    searchProfiles_nextToken,
    searchProfiles_domainName,
    searchProfiles_keyName,
    searchProfiles_values,

    -- * Destructuring the Response
    SearchProfilesResponse (..),
    newSearchProfilesResponse,

    -- * Response Lenses
    searchProfilesResponse_items,
    searchProfilesResponse_nextToken,
    searchProfilesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.CustomerProfiles.Types
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:/ 'newSearchProfiles' smart constructor.
data SearchProfiles = SearchProfiles'
  { -- | A list of @AdditionalSearchKey@ objects that are each searchable
    -- identifiers of a profile. Each @AdditionalSearchKey@ object contains a
    -- @KeyName@ and a list of @Values@ associated with that specific key
    -- (i.e., a key-value(s) pair). These additional search keys will be used
    -- in conjunction with the @LogicalOperator@ and the required @KeyName@ and
    -- @Values@ parameters to search for profiles that satisfy the search
    -- criteria.
    SearchProfiles -> Maybe (NonEmpty AdditionalSearchKey)
additionalSearchKeys :: Prelude.Maybe (Prelude.NonEmpty AdditionalSearchKey),
    -- | Relationship between all specified search keys that will be used to
    -- search for profiles. This includes the required @KeyName@ and @Values@
    -- parameters as well as any key-value(s) pairs specified in the
    -- @AdditionalSearchKeys@ list.
    --
    -- This parameter influences which profiles will be returned in the
    -- response in the following manner:
    --
    -- -   @AND@ - The response only includes profiles that match all of the
    --     search keys.
    --
    -- -   @OR@ - The response includes profiles that match at least one of the
    --     search keys.
    --
    -- The @OR@ relationship is the default behavior if this parameter is not
    -- included in the request.
    SearchProfiles -> Maybe LogicalOperator
logicalOperator :: Prelude.Maybe LogicalOperator,
    -- | The maximum number of objects returned per page.
    --
    -- The default is 20 if this parameter is not included in the request.
    SearchProfiles -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The pagination token from the previous SearchProfiles API call.
    SearchProfiles -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The unique name of the domain.
    SearchProfiles -> Text
domainName :: Prelude.Text,
    -- | A searchable identifier of a customer profile. The predefined keys you
    -- can use to search include: _account, _profileId, _assetId, _caseId,
    -- _orderId, _fullName, _phone, _email, _ctrContactId, _marketoLeadId,
    -- _salesforceAccountId, _salesforceContactId, _salesforceAssetId,
    -- _zendeskUserId, _zendeskExternalId, _zendeskTicketId,
    -- _serviceNowSystemId, _serviceNowIncidentId, _segmentUserId,
    -- _shopifyCustomerId, _shopifyOrderId.
    SearchProfiles -> Text
keyName :: Prelude.Text,
    -- | A list of key values.
    SearchProfiles -> [Text]
values :: [Prelude.Text]
  }
  deriving (SearchProfiles -> SearchProfiles -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchProfiles -> SearchProfiles -> Bool
$c/= :: SearchProfiles -> SearchProfiles -> Bool
== :: SearchProfiles -> SearchProfiles -> Bool
$c== :: SearchProfiles -> SearchProfiles -> Bool
Prelude.Eq, ReadPrec [SearchProfiles]
ReadPrec SearchProfiles
Int -> ReadS SearchProfiles
ReadS [SearchProfiles]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchProfiles]
$creadListPrec :: ReadPrec [SearchProfiles]
readPrec :: ReadPrec SearchProfiles
$creadPrec :: ReadPrec SearchProfiles
readList :: ReadS [SearchProfiles]
$creadList :: ReadS [SearchProfiles]
readsPrec :: Int -> ReadS SearchProfiles
$creadsPrec :: Int -> ReadS SearchProfiles
Prelude.Read, Int -> SearchProfiles -> ShowS
[SearchProfiles] -> ShowS
SearchProfiles -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchProfiles] -> ShowS
$cshowList :: [SearchProfiles] -> ShowS
show :: SearchProfiles -> String
$cshow :: SearchProfiles -> String
showsPrec :: Int -> SearchProfiles -> ShowS
$cshowsPrec :: Int -> SearchProfiles -> ShowS
Prelude.Show, forall x. Rep SearchProfiles x -> SearchProfiles
forall x. SearchProfiles -> Rep SearchProfiles x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchProfiles x -> SearchProfiles
$cfrom :: forall x. SearchProfiles -> Rep SearchProfiles x
Prelude.Generic)

-- |
-- Create a value of 'SearchProfiles' 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:
--
-- 'additionalSearchKeys', 'searchProfiles_additionalSearchKeys' - A list of @AdditionalSearchKey@ objects that are each searchable
-- identifiers of a profile. Each @AdditionalSearchKey@ object contains a
-- @KeyName@ and a list of @Values@ associated with that specific key
-- (i.e., a key-value(s) pair). These additional search keys will be used
-- in conjunction with the @LogicalOperator@ and the required @KeyName@ and
-- @Values@ parameters to search for profiles that satisfy the search
-- criteria.
--
-- 'logicalOperator', 'searchProfiles_logicalOperator' - Relationship between all specified search keys that will be used to
-- search for profiles. This includes the required @KeyName@ and @Values@
-- parameters as well as any key-value(s) pairs specified in the
-- @AdditionalSearchKeys@ list.
--
-- This parameter influences which profiles will be returned in the
-- response in the following manner:
--
-- -   @AND@ - The response only includes profiles that match all of the
--     search keys.
--
-- -   @OR@ - The response includes profiles that match at least one of the
--     search keys.
--
-- The @OR@ relationship is the default behavior if this parameter is not
-- included in the request.
--
-- 'maxResults', 'searchProfiles_maxResults' - The maximum number of objects returned per page.
--
-- The default is 20 if this parameter is not included in the request.
--
-- 'nextToken', 'searchProfiles_nextToken' - The pagination token from the previous SearchProfiles API call.
--
-- 'domainName', 'searchProfiles_domainName' - The unique name of the domain.
--
-- 'keyName', 'searchProfiles_keyName' - A searchable identifier of a customer profile. The predefined keys you
-- can use to search include: _account, _profileId, _assetId, _caseId,
-- _orderId, _fullName, _phone, _email, _ctrContactId, _marketoLeadId,
-- _salesforceAccountId, _salesforceContactId, _salesforceAssetId,
-- _zendeskUserId, _zendeskExternalId, _zendeskTicketId,
-- _serviceNowSystemId, _serviceNowIncidentId, _segmentUserId,
-- _shopifyCustomerId, _shopifyOrderId.
--
-- 'values', 'searchProfiles_values' - A list of key values.
newSearchProfiles ::
  -- | 'domainName'
  Prelude.Text ->
  -- | 'keyName'
  Prelude.Text ->
  SearchProfiles
newSearchProfiles :: Text -> Text -> SearchProfiles
newSearchProfiles Text
pDomainName_ Text
pKeyName_ =
  SearchProfiles'
    { $sel:additionalSearchKeys:SearchProfiles' :: Maybe (NonEmpty AdditionalSearchKey)
additionalSearchKeys =
        forall a. Maybe a
Prelude.Nothing,
      $sel:logicalOperator:SearchProfiles' :: Maybe LogicalOperator
logicalOperator = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:SearchProfiles' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:SearchProfiles' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:SearchProfiles' :: Text
domainName = Text
pDomainName_,
      $sel:keyName:SearchProfiles' :: Text
keyName = Text
pKeyName_,
      $sel:values:SearchProfiles' :: [Text]
values = forall a. Monoid a => a
Prelude.mempty
    }

-- | A list of @AdditionalSearchKey@ objects that are each searchable
-- identifiers of a profile. Each @AdditionalSearchKey@ object contains a
-- @KeyName@ and a list of @Values@ associated with that specific key
-- (i.e., a key-value(s) pair). These additional search keys will be used
-- in conjunction with the @LogicalOperator@ and the required @KeyName@ and
-- @Values@ parameters to search for profiles that satisfy the search
-- criteria.
searchProfiles_additionalSearchKeys :: Lens.Lens' SearchProfiles (Prelude.Maybe (Prelude.NonEmpty AdditionalSearchKey))
searchProfiles_additionalSearchKeys :: Lens' SearchProfiles (Maybe (NonEmpty AdditionalSearchKey))
searchProfiles_additionalSearchKeys = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProfiles' {Maybe (NonEmpty AdditionalSearchKey)
additionalSearchKeys :: Maybe (NonEmpty AdditionalSearchKey)
$sel:additionalSearchKeys:SearchProfiles' :: SearchProfiles -> Maybe (NonEmpty AdditionalSearchKey)
additionalSearchKeys} -> Maybe (NonEmpty AdditionalSearchKey)
additionalSearchKeys) (\s :: SearchProfiles
s@SearchProfiles' {} Maybe (NonEmpty AdditionalSearchKey)
a -> SearchProfiles
s {$sel:additionalSearchKeys:SearchProfiles' :: Maybe (NonEmpty AdditionalSearchKey)
additionalSearchKeys = Maybe (NonEmpty AdditionalSearchKey)
a} :: SearchProfiles) 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

-- | Relationship between all specified search keys that will be used to
-- search for profiles. This includes the required @KeyName@ and @Values@
-- parameters as well as any key-value(s) pairs specified in the
-- @AdditionalSearchKeys@ list.
--
-- This parameter influences which profiles will be returned in the
-- response in the following manner:
--
-- -   @AND@ - The response only includes profiles that match all of the
--     search keys.
--
-- -   @OR@ - The response includes profiles that match at least one of the
--     search keys.
--
-- The @OR@ relationship is the default behavior if this parameter is not
-- included in the request.
searchProfiles_logicalOperator :: Lens.Lens' SearchProfiles (Prelude.Maybe LogicalOperator)
searchProfiles_logicalOperator :: Lens' SearchProfiles (Maybe LogicalOperator)
searchProfiles_logicalOperator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProfiles' {Maybe LogicalOperator
logicalOperator :: Maybe LogicalOperator
$sel:logicalOperator:SearchProfiles' :: SearchProfiles -> Maybe LogicalOperator
logicalOperator} -> Maybe LogicalOperator
logicalOperator) (\s :: SearchProfiles
s@SearchProfiles' {} Maybe LogicalOperator
a -> SearchProfiles
s {$sel:logicalOperator:SearchProfiles' :: Maybe LogicalOperator
logicalOperator = Maybe LogicalOperator
a} :: SearchProfiles)

-- | The maximum number of objects returned per page.
--
-- The default is 20 if this parameter is not included in the request.
searchProfiles_maxResults :: Lens.Lens' SearchProfiles (Prelude.Maybe Prelude.Natural)
searchProfiles_maxResults :: Lens' SearchProfiles (Maybe Natural)
searchProfiles_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProfiles' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:SearchProfiles' :: SearchProfiles -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: SearchProfiles
s@SearchProfiles' {} Maybe Natural
a -> SearchProfiles
s {$sel:maxResults:SearchProfiles' :: Maybe Natural
maxResults = Maybe Natural
a} :: SearchProfiles)

-- | The pagination token from the previous SearchProfiles API call.
searchProfiles_nextToken :: Lens.Lens' SearchProfiles (Prelude.Maybe Prelude.Text)
searchProfiles_nextToken :: Lens' SearchProfiles (Maybe Text)
searchProfiles_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProfiles' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchProfiles' :: SearchProfiles -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchProfiles
s@SearchProfiles' {} Maybe Text
a -> SearchProfiles
s {$sel:nextToken:SearchProfiles' :: Maybe Text
nextToken = Maybe Text
a} :: SearchProfiles)

-- | The unique name of the domain.
searchProfiles_domainName :: Lens.Lens' SearchProfiles Prelude.Text
searchProfiles_domainName :: Lens' SearchProfiles Text
searchProfiles_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProfiles' {Text
domainName :: Text
$sel:domainName:SearchProfiles' :: SearchProfiles -> Text
domainName} -> Text
domainName) (\s :: SearchProfiles
s@SearchProfiles' {} Text
a -> SearchProfiles
s {$sel:domainName:SearchProfiles' :: Text
domainName = Text
a} :: SearchProfiles)

-- | A searchable identifier of a customer profile. The predefined keys you
-- can use to search include: _account, _profileId, _assetId, _caseId,
-- _orderId, _fullName, _phone, _email, _ctrContactId, _marketoLeadId,
-- _salesforceAccountId, _salesforceContactId, _salesforceAssetId,
-- _zendeskUserId, _zendeskExternalId, _zendeskTicketId,
-- _serviceNowSystemId, _serviceNowIncidentId, _segmentUserId,
-- _shopifyCustomerId, _shopifyOrderId.
searchProfiles_keyName :: Lens.Lens' SearchProfiles Prelude.Text
searchProfiles_keyName :: Lens' SearchProfiles Text
searchProfiles_keyName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProfiles' {Text
keyName :: Text
$sel:keyName:SearchProfiles' :: SearchProfiles -> Text
keyName} -> Text
keyName) (\s :: SearchProfiles
s@SearchProfiles' {} Text
a -> SearchProfiles
s {$sel:keyName:SearchProfiles' :: Text
keyName = Text
a} :: SearchProfiles)

-- | A list of key values.
searchProfiles_values :: Lens.Lens' SearchProfiles [Prelude.Text]
searchProfiles_values :: Lens' SearchProfiles [Text]
searchProfiles_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProfiles' {[Text]
values :: [Text]
$sel:values:SearchProfiles' :: SearchProfiles -> [Text]
values} -> [Text]
values) (\s :: SearchProfiles
s@SearchProfiles' {} [Text]
a -> SearchProfiles
s {$sel:values:SearchProfiles' :: [Text]
values = [Text]
a} :: SearchProfiles) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest SearchProfiles where
  type
    AWSResponse SearchProfiles =
      SearchProfilesResponse
  request :: (Service -> Service) -> SearchProfiles -> Request SearchProfiles
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy SearchProfiles
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SearchProfiles)))
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 [Profile] -> Maybe Text -> Int -> SearchProfilesResponse
SearchProfilesResponse'
            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
"Items" 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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextToken")
            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 SearchProfiles where
  hashWithSalt :: Int -> SearchProfiles -> Int
hashWithSalt Int
_salt SearchProfiles' {[Text]
Maybe Natural
Maybe (NonEmpty AdditionalSearchKey)
Maybe Text
Maybe LogicalOperator
Text
values :: [Text]
keyName :: Text
domainName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
logicalOperator :: Maybe LogicalOperator
additionalSearchKeys :: Maybe (NonEmpty AdditionalSearchKey)
$sel:values:SearchProfiles' :: SearchProfiles -> [Text]
$sel:keyName:SearchProfiles' :: SearchProfiles -> Text
$sel:domainName:SearchProfiles' :: SearchProfiles -> Text
$sel:nextToken:SearchProfiles' :: SearchProfiles -> Maybe Text
$sel:maxResults:SearchProfiles' :: SearchProfiles -> Maybe Natural
$sel:logicalOperator:SearchProfiles' :: SearchProfiles -> Maybe LogicalOperator
$sel:additionalSearchKeys:SearchProfiles' :: SearchProfiles -> Maybe (NonEmpty AdditionalSearchKey)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty AdditionalSearchKey)
additionalSearchKeys
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LogicalOperator
logicalOperator
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
keyName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
values

instance Prelude.NFData SearchProfiles where
  rnf :: SearchProfiles -> ()
rnf SearchProfiles' {[Text]
Maybe Natural
Maybe (NonEmpty AdditionalSearchKey)
Maybe Text
Maybe LogicalOperator
Text
values :: [Text]
keyName :: Text
domainName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
logicalOperator :: Maybe LogicalOperator
additionalSearchKeys :: Maybe (NonEmpty AdditionalSearchKey)
$sel:values:SearchProfiles' :: SearchProfiles -> [Text]
$sel:keyName:SearchProfiles' :: SearchProfiles -> Text
$sel:domainName:SearchProfiles' :: SearchProfiles -> Text
$sel:nextToken:SearchProfiles' :: SearchProfiles -> Maybe Text
$sel:maxResults:SearchProfiles' :: SearchProfiles -> Maybe Natural
$sel:logicalOperator:SearchProfiles' :: SearchProfiles -> Maybe LogicalOperator
$sel:additionalSearchKeys:SearchProfiles' :: SearchProfiles -> Maybe (NonEmpty AdditionalSearchKey)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty AdditionalSearchKey)
additionalSearchKeys
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe LogicalOperator
logicalOperator
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
domainName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
keyName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
values

instance Data.ToHeaders SearchProfiles where
  toHeaders :: SearchProfiles -> 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.ToJSON SearchProfiles where
  toJSON :: SearchProfiles -> Value
toJSON SearchProfiles' {[Text]
Maybe Natural
Maybe (NonEmpty AdditionalSearchKey)
Maybe Text
Maybe LogicalOperator
Text
values :: [Text]
keyName :: Text
domainName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
logicalOperator :: Maybe LogicalOperator
additionalSearchKeys :: Maybe (NonEmpty AdditionalSearchKey)
$sel:values:SearchProfiles' :: SearchProfiles -> [Text]
$sel:keyName:SearchProfiles' :: SearchProfiles -> Text
$sel:domainName:SearchProfiles' :: SearchProfiles -> Text
$sel:nextToken:SearchProfiles' :: SearchProfiles -> Maybe Text
$sel:maxResults:SearchProfiles' :: SearchProfiles -> Maybe Natural
$sel:logicalOperator:SearchProfiles' :: SearchProfiles -> Maybe LogicalOperator
$sel:additionalSearchKeys:SearchProfiles' :: SearchProfiles -> Maybe (NonEmpty AdditionalSearchKey)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AdditionalSearchKeys" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty AdditionalSearchKey)
additionalSearchKeys,
            (Key
"LogicalOperator" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LogicalOperator
logicalOperator,
            forall a. a -> Maybe a
Prelude.Just (Key
"KeyName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
keyName),
            forall a. a -> Maybe a
Prelude.Just (Key
"Values" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
values)
          ]
      )

instance Data.ToPath SearchProfiles where
  toPath :: SearchProfiles -> ByteString
toPath SearchProfiles' {[Text]
Maybe Natural
Maybe (NonEmpty AdditionalSearchKey)
Maybe Text
Maybe LogicalOperator
Text
values :: [Text]
keyName :: Text
domainName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
logicalOperator :: Maybe LogicalOperator
additionalSearchKeys :: Maybe (NonEmpty AdditionalSearchKey)
$sel:values:SearchProfiles' :: SearchProfiles -> [Text]
$sel:keyName:SearchProfiles' :: SearchProfiles -> Text
$sel:domainName:SearchProfiles' :: SearchProfiles -> Text
$sel:nextToken:SearchProfiles' :: SearchProfiles -> Maybe Text
$sel:maxResults:SearchProfiles' :: SearchProfiles -> Maybe Natural
$sel:logicalOperator:SearchProfiles' :: SearchProfiles -> Maybe LogicalOperator
$sel:additionalSearchKeys:SearchProfiles' :: SearchProfiles -> Maybe (NonEmpty AdditionalSearchKey)
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/domains/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
domainName,
        ByteString
"/profiles/search"
      ]

instance Data.ToQuery SearchProfiles where
  toQuery :: SearchProfiles -> QueryString
toQuery SearchProfiles' {[Text]
Maybe Natural
Maybe (NonEmpty AdditionalSearchKey)
Maybe Text
Maybe LogicalOperator
Text
values :: [Text]
keyName :: Text
domainName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
logicalOperator :: Maybe LogicalOperator
additionalSearchKeys :: Maybe (NonEmpty AdditionalSearchKey)
$sel:values:SearchProfiles' :: SearchProfiles -> [Text]
$sel:keyName:SearchProfiles' :: SearchProfiles -> Text
$sel:domainName:SearchProfiles' :: SearchProfiles -> Text
$sel:nextToken:SearchProfiles' :: SearchProfiles -> Maybe Text
$sel:maxResults:SearchProfiles' :: SearchProfiles -> Maybe Natural
$sel:logicalOperator:SearchProfiles' :: SearchProfiles -> Maybe LogicalOperator
$sel:additionalSearchKeys:SearchProfiles' :: SearchProfiles -> Maybe (NonEmpty AdditionalSearchKey)
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"max-results" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"next-token" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newSearchProfilesResponse' smart constructor.
data SearchProfilesResponse = SearchProfilesResponse'
  { -- | The list of Profiles matching the search criteria.
    SearchProfilesResponse -> Maybe [Profile]
items :: Prelude.Maybe [Profile],
    -- | The pagination token from the previous SearchProfiles API call.
    SearchProfilesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    SearchProfilesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SearchProfilesResponse -> SearchProfilesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchProfilesResponse -> SearchProfilesResponse -> Bool
$c/= :: SearchProfilesResponse -> SearchProfilesResponse -> Bool
== :: SearchProfilesResponse -> SearchProfilesResponse -> Bool
$c== :: SearchProfilesResponse -> SearchProfilesResponse -> Bool
Prelude.Eq, ReadPrec [SearchProfilesResponse]
ReadPrec SearchProfilesResponse
Int -> ReadS SearchProfilesResponse
ReadS [SearchProfilesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchProfilesResponse]
$creadListPrec :: ReadPrec [SearchProfilesResponse]
readPrec :: ReadPrec SearchProfilesResponse
$creadPrec :: ReadPrec SearchProfilesResponse
readList :: ReadS [SearchProfilesResponse]
$creadList :: ReadS [SearchProfilesResponse]
readsPrec :: Int -> ReadS SearchProfilesResponse
$creadsPrec :: Int -> ReadS SearchProfilesResponse
Prelude.Read, Int -> SearchProfilesResponse -> ShowS
[SearchProfilesResponse] -> ShowS
SearchProfilesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchProfilesResponse] -> ShowS
$cshowList :: [SearchProfilesResponse] -> ShowS
show :: SearchProfilesResponse -> String
$cshow :: SearchProfilesResponse -> String
showsPrec :: Int -> SearchProfilesResponse -> ShowS
$cshowsPrec :: Int -> SearchProfilesResponse -> ShowS
Prelude.Show, forall x. Rep SearchProfilesResponse x -> SearchProfilesResponse
forall x. SearchProfilesResponse -> Rep SearchProfilesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchProfilesResponse x -> SearchProfilesResponse
$cfrom :: forall x. SearchProfilesResponse -> Rep SearchProfilesResponse x
Prelude.Generic)

-- |
-- Create a value of 'SearchProfilesResponse' 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:
--
-- 'items', 'searchProfilesResponse_items' - The list of Profiles matching the search criteria.
--
-- 'nextToken', 'searchProfilesResponse_nextToken' - The pagination token from the previous SearchProfiles API call.
--
-- 'httpStatus', 'searchProfilesResponse_httpStatus' - The response's http status code.
newSearchProfilesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SearchProfilesResponse
newSearchProfilesResponse :: Int -> SearchProfilesResponse
newSearchProfilesResponse Int
pHttpStatus_ =
  SearchProfilesResponse'
    { $sel:items:SearchProfilesResponse' :: Maybe [Profile]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:SearchProfilesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SearchProfilesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of Profiles matching the search criteria.
searchProfilesResponse_items :: Lens.Lens' SearchProfilesResponse (Prelude.Maybe [Profile])
searchProfilesResponse_items :: Lens' SearchProfilesResponse (Maybe [Profile])
searchProfilesResponse_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProfilesResponse' {Maybe [Profile]
items :: Maybe [Profile]
$sel:items:SearchProfilesResponse' :: SearchProfilesResponse -> Maybe [Profile]
items} -> Maybe [Profile]
items) (\s :: SearchProfilesResponse
s@SearchProfilesResponse' {} Maybe [Profile]
a -> SearchProfilesResponse
s {$sel:items:SearchProfilesResponse' :: Maybe [Profile]
items = Maybe [Profile]
a} :: SearchProfilesResponse) 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 pagination token from the previous SearchProfiles API call.
searchProfilesResponse_nextToken :: Lens.Lens' SearchProfilesResponse (Prelude.Maybe Prelude.Text)
searchProfilesResponse_nextToken :: Lens' SearchProfilesResponse (Maybe Text)
searchProfilesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProfilesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchProfilesResponse' :: SearchProfilesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchProfilesResponse
s@SearchProfilesResponse' {} Maybe Text
a -> SearchProfilesResponse
s {$sel:nextToken:SearchProfilesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: SearchProfilesResponse)

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

instance Prelude.NFData SearchProfilesResponse where
  rnf :: SearchProfilesResponse -> ()
rnf SearchProfilesResponse' {Int
Maybe [Profile]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
items :: Maybe [Profile]
$sel:httpStatus:SearchProfilesResponse' :: SearchProfilesResponse -> Int
$sel:nextToken:SearchProfilesResponse' :: SearchProfilesResponse -> Maybe Text
$sel:items:SearchProfilesResponse' :: SearchProfilesResponse -> Maybe [Profile]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Profile]
items
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus