{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric      #-}
{-# LANGUAGE NoImplicitPrelude  #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE RecordWildCards    #-}

{-# OPTIONS_GHC -fno-warn-unused-binds   #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}

-- |
-- Module      : Network.Google.CloudSearch.Types.Product
-- Copyright   : (c) 2015-2016 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
module Network.Google.CloudSearch.Types.Product where

import           Network.Google.CloudSearch.Types.Sum
import           Network.Google.Prelude

-- | Gmail Folder restricts (i.e. in Drafts\/Sent\/Chats\/User Generated
-- Labels).
--
-- /See:/ 'gmailFolderRestrict' smart constructor.
newtype GmailFolderRestrict =
  GmailFolderRestrict'
    { _gfrType :: Maybe GmailFolderRestrictType
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'GmailFolderRestrict' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'gfrType'
gmailFolderRestrict
    :: GmailFolderRestrict
gmailFolderRestrict = GmailFolderRestrict' {_gfrType = Nothing}


gfrType :: Lens' GmailFolderRestrict (Maybe GmailFolderRestrictType)
gfrType = lens _gfrType (\ s a -> s{_gfrType = a})

instance FromJSON GmailFolderRestrict where
        parseJSON
          = withObject "GmailFolderRestrict"
              (\ o -> GmailFolderRestrict' <$> (o .:? "type"))

instance ToJSON GmailFolderRestrict where
        toJSON GmailFolderRestrict'{..}
          = object (catMaybes [("type" .=) <$> _gfrType])

-- | Content of an item to be indexed and surfaced by Cloud Search.
--
-- /See:/ 'itemContent' smart constructor.
data ItemContent =
  ItemContent'
    { _icHash           :: !(Maybe Text)
    , _icContentFormat  :: !(Maybe ItemContentContentFormat)
    , _icContentDataRef :: !(Maybe UploadItemRef)
    , _icInlineContent  :: !(Maybe Bytes)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ItemContent' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'icHash'
--
-- * 'icContentFormat'
--
-- * 'icContentDataRef'
--
-- * 'icInlineContent'
itemContent
    :: ItemContent
itemContent =
  ItemContent'
    { _icHash = Nothing
    , _icContentFormat = Nothing
    , _icContentDataRef = Nothing
    , _icInlineContent = Nothing
    }


-- | Hashing info calculated and provided by the API client for content. Can
-- be used with the items.push method to calculate modified state. The
-- maximum length is 2048 characters.
icHash :: Lens' ItemContent (Maybe Text)
icHash = lens _icHash (\ s a -> s{_icHash = a})

icContentFormat :: Lens' ItemContent (Maybe ItemContentContentFormat)
icContentFormat
  = lens _icContentFormat
      (\ s a -> s{_icContentFormat = a})

-- | Upload reference ID of a previously uploaded content via write method.
icContentDataRef :: Lens' ItemContent (Maybe UploadItemRef)
icContentDataRef
  = lens _icContentDataRef
      (\ s a -> s{_icContentDataRef = a})

-- | Content that is supplied inlined within the update method. The maximum
-- length is 102400 bytes (100 KiB).
icInlineContent :: Lens' ItemContent (Maybe ByteString)
icInlineContent
  = lens _icInlineContent
      (\ s a -> s{_icInlineContent = a})
      . mapping _Bytes

instance FromJSON ItemContent where
        parseJSON
          = withObject "ItemContent"
              (\ o ->
                 ItemContent' <$>
                   (o .:? "hash") <*> (o .:? "contentFormat") <*>
                     (o .:? "contentDataRef")
                     <*> (o .:? "inlineContent"))

instance ToJSON ItemContent where
        toJSON ItemContent'{..}
          = object
              (catMaybes
                 [("hash" .=) <$> _icHash,
                  ("contentFormat" .=) <$> _icContentFormat,
                  ("contentDataRef" .=) <$> _icContentDataRef,
                  ("inlineContent" .=) <$> _icInlineContent])

-- | A person\'s photo.
--
-- /See:/ 'photo' smart constructor.
newtype Photo =
  Photo'
    { _pURL :: Maybe Text
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'Photo' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'pURL'
photo
    :: Photo
photo = Photo' {_pURL = Nothing}


-- | The URL of the photo.
pURL :: Lens' Photo (Maybe Text)
pURL = lens _pURL (\ s a -> s{_pURL = a})

instance FromJSON Photo where
        parseJSON
          = withObject "Photo"
              (\ o -> Photo' <$> (o .:? "url"))

instance ToJSON Photo where
        toJSON Photo'{..}
          = object (catMaybes [("url" .=) <$> _pURL])

--
-- /See:/ 'searchItemsByViewURLRequest' smart constructor.
data SearchItemsByViewURLRequest =
  SearchItemsByViewURLRequest'
    { _sibvurDebugOptions :: !(Maybe DebugOptions)
    , _sibvurPageToken    :: !(Maybe Text)
    , _sibvurViewURL      :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'SearchItemsByViewURLRequest' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'sibvurDebugOptions'
--
-- * 'sibvurPageToken'
--
-- * 'sibvurViewURL'
searchItemsByViewURLRequest
    :: SearchItemsByViewURLRequest
searchItemsByViewURLRequest =
  SearchItemsByViewURLRequest'
    { _sibvurDebugOptions = Nothing
    , _sibvurPageToken = Nothing
    , _sibvurViewURL = Nothing
    }


-- | Common debug options.
sibvurDebugOptions :: Lens' SearchItemsByViewURLRequest (Maybe DebugOptions)
sibvurDebugOptions
  = lens _sibvurDebugOptions
      (\ s a -> s{_sibvurDebugOptions = a})

-- | The next_page_token value returned from a previous request, if any.
sibvurPageToken :: Lens' SearchItemsByViewURLRequest (Maybe Text)
sibvurPageToken
  = lens _sibvurPageToken
      (\ s a -> s{_sibvurPageToken = a})

-- | Specify the full view URL to find the corresponding item. The maximum
-- length is 2048 characters.
sibvurViewURL :: Lens' SearchItemsByViewURLRequest (Maybe Text)
sibvurViewURL
  = lens _sibvurViewURL
      (\ s a -> s{_sibvurViewURL = a})

instance FromJSON SearchItemsByViewURLRequest where
        parseJSON
          = withObject "SearchItemsByViewURLRequest"
              (\ o ->
                 SearchItemsByViewURLRequest' <$>
                   (o .:? "debugOptions") <*> (o .:? "pageToken") <*>
                     (o .:? "viewUrl"))

instance ToJSON SearchItemsByViewURLRequest where
        toJSON SearchItemsByViewURLRequest'{..}
          = object
              (catMaybes
                 [("debugOptions" .=) <$> _sibvurDebugOptions,
                  ("pageToken" .=) <$> _sibvurPageToken,
                  ("viewUrl" .=) <$> _sibvurViewURL])

-- | SearchApplication
--
-- /See:/ 'searchApplication' smart constructor.
data SearchApplication =
  SearchApplication'
    { _saDataSourceRestrictions :: !(Maybe [DataSourceRestriction])
    , _saOperationIds           :: !(Maybe [Text])
    , _saDefaultFacetOptions    :: !(Maybe [FacetOptions])
    , _saScoringConfig          :: !(Maybe ScoringConfig)
    , _saName                   :: !(Maybe Text)
    , _saSourceConfig           :: !(Maybe [SourceConfig])
    , _saDisplayName            :: !(Maybe Text)
    , _saDefaultSortOptions     :: !(Maybe SortOptions)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'SearchApplication' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'saDataSourceRestrictions'
--
-- * 'saOperationIds'
--
-- * 'saDefaultFacetOptions'
--
-- * 'saScoringConfig'
--
-- * 'saName'
--
-- * 'saSourceConfig'
--
-- * 'saDisplayName'
--
-- * 'saDefaultSortOptions'
searchApplication
    :: SearchApplication
searchApplication =
  SearchApplication'
    { _saDataSourceRestrictions = Nothing
    , _saOperationIds = Nothing
    , _saDefaultFacetOptions = Nothing
    , _saScoringConfig = Nothing
    , _saName = Nothing
    , _saSourceConfig = Nothing
    , _saDisplayName = Nothing
    , _saDefaultSortOptions = Nothing
    }


-- | Retrictions applied to the configurations. The maximum number of
-- elements is 10.
saDataSourceRestrictions :: Lens' SearchApplication [DataSourceRestriction]
saDataSourceRestrictions
  = lens _saDataSourceRestrictions
      (\ s a -> s{_saDataSourceRestrictions = a})
      . _Default
      . _Coerce

-- | IDs of the Long Running Operations (LROs) currently running for this
-- schema. Output only field.
saOperationIds :: Lens' SearchApplication [Text]
saOperationIds
  = lens _saOperationIds
      (\ s a -> s{_saOperationIds = a})
      . _Default
      . _Coerce

-- | The default fields for returning facet results. The sources specified
-- here also have been included in data_source_restrictions above.
saDefaultFacetOptions :: Lens' SearchApplication [FacetOptions]
saDefaultFacetOptions
  = lens _saDefaultFacetOptions
      (\ s a -> s{_saDefaultFacetOptions = a})
      . _Default
      . _Coerce

-- | Configuration for ranking results.
saScoringConfig :: Lens' SearchApplication (Maybe ScoringConfig)
saScoringConfig
  = lens _saScoringConfig
      (\ s a -> s{_saScoringConfig = a})

-- | Name of the Search Application.
-- Format: searchapplications\/{application_id}.
saName :: Lens' SearchApplication (Maybe Text)
saName = lens _saName (\ s a -> s{_saName = a})

-- | Configuration for a sources specified in data_source_restrictions.
saSourceConfig :: Lens' SearchApplication [SourceConfig]
saSourceConfig
  = lens _saSourceConfig
      (\ s a -> s{_saSourceConfig = a})
      . _Default
      . _Coerce

-- | Display name of the Search Application. The maximum length is 300
-- characters.
saDisplayName :: Lens' SearchApplication (Maybe Text)
saDisplayName
  = lens _saDisplayName
      (\ s a -> s{_saDisplayName = a})

-- | The default options for sorting the search results
saDefaultSortOptions :: Lens' SearchApplication (Maybe SortOptions)
saDefaultSortOptions
  = lens _saDefaultSortOptions
      (\ s a -> s{_saDefaultSortOptions = a})

instance FromJSON SearchApplication where
        parseJSON
          = withObject "SearchApplication"
              (\ o ->
                 SearchApplication' <$>
                   (o .:? "dataSourceRestrictions" .!= mempty) <*>
                     (o .:? "operationIds" .!= mempty)
                     <*> (o .:? "defaultFacetOptions" .!= mempty)
                     <*> (o .:? "scoringConfig")
                     <*> (o .:? "name")
                     <*> (o .:? "sourceConfig" .!= mempty)
                     <*> (o .:? "displayName")
                     <*> (o .:? "defaultSortOptions"))

instance ToJSON SearchApplication where
        toJSON SearchApplication'{..}
          = object
              (catMaybes
                 [("dataSourceRestrictions" .=) <$>
                    _saDataSourceRestrictions,
                  ("operationIds" .=) <$> _saOperationIds,
                  ("defaultFacetOptions" .=) <$>
                    _saDefaultFacetOptions,
                  ("scoringConfig" .=) <$> _saScoringConfig,
                  ("name" .=) <$> _saName,
                  ("sourceConfig" .=) <$> _saSourceConfig,
                  ("displayName" .=) <$> _saDisplayName,
                  ("defaultSortOptions" .=) <$> _saDefaultSortOptions])

-- | Used to provide a search operator for boolean properties. This is
-- optional. Search operators let users restrict the query to specific
-- fields relevant to the type of item being searched.
--
-- /See:/ 'booleanOperatorOptions' smart constructor.
newtype BooleanOperatorOptions =
  BooleanOperatorOptions'
    { _booOperatorName :: Maybe Text
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'BooleanOperatorOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'booOperatorName'
booleanOperatorOptions
    :: BooleanOperatorOptions
booleanOperatorOptions = BooleanOperatorOptions' {_booOperatorName = Nothing}


-- | Indicates the operator name required in the query in order to isolate
-- the boolean property. For example, if operatorName is *closed* and the
-- property\'s name is *isClosed*, then queries like *closed:\<value>* will
-- show results only where the value of the property named *isClosed*
-- matches *\<value>*. By contrast, a search that uses the same *\<value>*
-- without an operator will return all items where *\<value>* matches the
-- value of any String properties or text within the content field for the
-- item. The operator name can only contain lowercase letters (a-z). The
-- maximum length is 32 characters.
booOperatorName :: Lens' BooleanOperatorOptions (Maybe Text)
booOperatorName
  = lens _booOperatorName
      (\ s a -> s{_booOperatorName = a})

instance FromJSON BooleanOperatorOptions where
        parseJSON
          = withObject "BooleanOperatorOptions"
              (\ o ->
                 BooleanOperatorOptions' <$> (o .:? "operatorName"))

instance ToJSON BooleanOperatorOptions where
        toJSON BooleanOperatorOptions'{..}
          = object
              (catMaybes
                 [("operatorName" .=) <$> _booOperatorName])

-- | The \`Status\` type defines a logical error model that is suitable for
-- different programming environments, including REST APIs and RPC APIs. It
-- is used by [gRPC](https:\/\/github.com\/grpc). The error model is
-- designed to be: - Simple to use and understand for most users - Flexible
-- enough to meet unexpected needs # Overview The \`Status\` message
-- contains three pieces of data: error code, error message, and error
-- details. The error code should be an enum value of google.rpc.Code, but
-- it may accept additional error codes if needed. The error message should
-- be a developer-facing English message that helps developers *understand*
-- and *resolve* the error. If a localized user-facing error message is
-- needed, put the localized message in the error details or localize it in
-- the client. The optional error details may contain arbitrary information
-- about the error. There is a predefined set of error detail types in the
-- package \`google.rpc\` that can be used for common error conditions. #
-- Language mapping The \`Status\` message is the logical representation of
-- the error model, but it is not necessarily the actual wire format. When
-- the \`Status\` message is exposed in different client libraries and
-- different wire protocols, it can be mapped differently. For example, it
-- will likely be mapped to some exceptions in Java, but more likely mapped
-- to some error codes in C. # Other uses The error model and the
-- \`Status\` message can be used in a variety of environments, either with
-- or without APIs, to provide a consistent developer experience across
-- different environments. Example uses of this error model include: -
-- Partial errors. If a service needs to return partial errors to the
-- client, it may embed the \`Status\` in the normal response to indicate
-- the partial errors. - Workflow errors. A typical workflow has multiple
-- steps. Each step may have a \`Status\` message for error reporting. -
-- Batch operations. If a client uses batch request and batch response, the
-- \`Status\` message should be used directly inside batch response, one
-- for each error sub-response. - Asynchronous operations. If an API call
-- embeds asynchronous operation results in its response, the status of
-- those operations should be represented directly using the \`Status\`
-- message. - Logging. If some API errors are stored in logs, the message
-- \`Status\` could be used directly after any stripping needed for
-- security\/privacy reasons.
--
-- /See:/ 'status' smart constructor.
data Status =
  Status'
    { _sDetails :: !(Maybe [StatusDetailsItem])
    , _sCode    :: !(Maybe (Textual Int32))
    , _sMessage :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'Status' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'sDetails'
--
-- * 'sCode'
--
-- * 'sMessage'
status
    :: Status
status = Status' {_sDetails = Nothing, _sCode = Nothing, _sMessage = Nothing}


-- | A list of messages that carry the error details. There is a common set
-- of message types for APIs to use.
sDetails :: Lens' Status [StatusDetailsItem]
sDetails
  = lens _sDetails (\ s a -> s{_sDetails = a}) .
      _Default
      . _Coerce

-- | The status code, which should be an enum value of google.rpc.Code.
sCode :: Lens' Status (Maybe Int32)
sCode
  = lens _sCode (\ s a -> s{_sCode = a}) .
      mapping _Coerce

-- | A developer-facing error message, which should be in English. Any
-- user-facing error message should be localized and sent in the
-- google.rpc.Status.details field, or localized by the client.
sMessage :: Lens' Status (Maybe Text)
sMessage = lens _sMessage (\ s a -> s{_sMessage = a})

instance FromJSON Status where
        parseJSON
          = withObject "Status"
              (\ o ->
                 Status' <$>
                   (o .:? "details" .!= mempty) <*> (o .:? "code") <*>
                     (o .:? "message"))

instance ToJSON Status where
        toJSON Status'{..}
          = object
              (catMaybes
                 [("details" .=) <$> _sDetails,
                  ("code" .=) <$> _sCode,
                  ("message" .=) <$> _sMessage])

-- | Options for enum properties, which allow you to define a restricted set
-- of strings to match user queries, set rankings for those string values,
-- and define an operator name to be paired with those strings so that
-- users can narrow results to only items with a specific value. For
-- example, for items in a request tracking system with priority
-- information, you could define *p0* as an allowable enum value and tie
-- this enum to the operator name *priority* so that search users could add
-- *priority:p0* to their query to restrict the set of results to only
-- those items indexed with the value *p0*.
--
-- /See:/ 'enumPropertyOptions' smart constructor.
data EnumPropertyOptions =
  EnumPropertyOptions'
    { _epoPossibleValues  :: !(Maybe [EnumValuePair])
    , _epoOrderedRanking  :: !(Maybe EnumPropertyOptionsOrderedRanking)
    , _epoOperatorOptions :: !(Maybe EnumOperatorOptions)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'EnumPropertyOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'epoPossibleValues'
--
-- * 'epoOrderedRanking'
--
-- * 'epoOperatorOptions'
enumPropertyOptions
    :: EnumPropertyOptions
enumPropertyOptions =
  EnumPropertyOptions'
    { _epoPossibleValues = Nothing
    , _epoOrderedRanking = Nothing
    , _epoOperatorOptions = Nothing
    }


-- | The list of possible values for the enumeration property. All
-- EnumValuePairs must provide a string value. If you specify an integer
-- value for one EnumValuePair, then all possible EnumValuePairs must
-- provide an integer value. Both the string value and integer value must
-- be unique over all possible values. Once set, possible values cannot be
-- removed or modified. If you supply an ordered ranking and think you
-- might insert additional enum values in the future, leave gaps in the
-- initial integer values to allow adding a value in between previously
-- registered values. The maximum number of elements is 100.
epoPossibleValues :: Lens' EnumPropertyOptions [EnumValuePair]
epoPossibleValues
  = lens _epoPossibleValues
      (\ s a -> s{_epoPossibleValues = a})
      . _Default
      . _Coerce

-- | Used to specify the ordered ranking for the enumeration that determines
-- how the integer values provided in the possible EnumValuePairs are used
-- to rank results. If specified, integer values must be provided for all
-- possible EnumValuePair values given for this property. Can only be used
-- if isRepeatable is false.
epoOrderedRanking :: Lens' EnumPropertyOptions (Maybe EnumPropertyOptionsOrderedRanking)
epoOrderedRanking
  = lens _epoOrderedRanking
      (\ s a -> s{_epoOrderedRanking = a})

-- | If set, describes how the enum should be used as a search operator.
epoOperatorOptions :: Lens' EnumPropertyOptions (Maybe EnumOperatorOptions)
epoOperatorOptions
  = lens _epoOperatorOptions
      (\ s a -> s{_epoOperatorOptions = a})

instance FromJSON EnumPropertyOptions where
        parseJSON
          = withObject "EnumPropertyOptions"
              (\ o ->
                 EnumPropertyOptions' <$>
                   (o .:? "possibleValues" .!= mempty) <*>
                     (o .:? "orderedRanking")
                     <*> (o .:? "operatorOptions"))

instance ToJSON EnumPropertyOptions where
        toJSON EnumPropertyOptions'{..}
          = object
              (catMaybes
                 [("possibleValues" .=) <$> _epoPossibleValues,
                  ("orderedRanking" .=) <$> _epoOrderedRanking,
                  ("operatorOptions" .=) <$> _epoOperatorOptions])

-- | Gmail Action restricts (i.e. read\/replied\/snoozed).
--
-- /See:/ 'gmailActionRestrict' smart constructor.
newtype GmailActionRestrict =
  GmailActionRestrict'
    { _garType :: Maybe GmailActionRestrictType
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'GmailActionRestrict' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'garType'
gmailActionRestrict
    :: GmailActionRestrict
gmailActionRestrict = GmailActionRestrict' {_garType = Nothing}


garType :: Lens' GmailActionRestrict (Maybe GmailActionRestrictType)
garType = lens _garType (\ s a -> s{_garType = a})

instance FromJSON GmailActionRestrict where
        parseJSON
          = withObject "GmailActionRestrict"
              (\ o -> GmailActionRestrict' <$> (o .:? "type"))

instance ToJSON GmailActionRestrict where
        toJSON GmailActionRestrict'{..}
          = object (catMaybes [("type" .=) <$> _garType])

--
-- /See:/ 'unreserveItemsRequest' smart constructor.
data UnreserveItemsRequest =
  UnreserveItemsRequest'
    { _uirQueue         :: !(Maybe Text)
    , _uirDebugOptions  :: !(Maybe DebugOptions)
    , _uirConnectorName :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'UnreserveItemsRequest' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'uirQueue'
--
-- * 'uirDebugOptions'
--
-- * 'uirConnectorName'
unreserveItemsRequest
    :: UnreserveItemsRequest
unreserveItemsRequest =
  UnreserveItemsRequest'
    { _uirQueue = Nothing
    , _uirDebugOptions = Nothing
    , _uirConnectorName = Nothing
    }


-- | Name of a queue to unreserve items from.
uirQueue :: Lens' UnreserveItemsRequest (Maybe Text)
uirQueue = lens _uirQueue (\ s a -> s{_uirQueue = a})

-- | Common debug options.
uirDebugOptions :: Lens' UnreserveItemsRequest (Maybe DebugOptions)
uirDebugOptions
  = lens _uirDebugOptions
      (\ s a -> s{_uirDebugOptions = a})

-- | Name of connector making this call.
-- Format: datasources\/{source_id}\/connectors\/{ID}
uirConnectorName :: Lens' UnreserveItemsRequest (Maybe Text)
uirConnectorName
  = lens _uirConnectorName
      (\ s a -> s{_uirConnectorName = a})

instance FromJSON UnreserveItemsRequest where
        parseJSON
          = withObject "UnreserveItemsRequest"
              (\ o ->
                 UnreserveItemsRequest' <$>
                   (o .:? "queue") <*> (o .:? "debugOptions") <*>
                     (o .:? "connectorName"))

instance ToJSON UnreserveItemsRequest where
        toJSON UnreserveItemsRequest'{..}
          = object
              (catMaybes
                 [("queue" .=) <$> _uirQueue,
                  ("debugOptions" .=) <$> _uirDebugOptions,
                  ("connectorName" .=) <$> _uirConnectorName])

-- | Optional. Provides a search operator for date properties. Search
-- operators let users restrict the query to specific fields relevant to
-- the type of item being searched.
--
-- /See:/ 'dateOperatorOptions' smart constructor.
data DateOperatorOptions =
  DateOperatorOptions'
    { _dooOperatorName            :: !(Maybe Text)
    , _dooLessThanOperatorName    :: !(Maybe Text)
    , _dooGreaterThanOperatorName :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'DateOperatorOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'dooOperatorName'
--
-- * 'dooLessThanOperatorName'
--
-- * 'dooGreaterThanOperatorName'
dateOperatorOptions
    :: DateOperatorOptions
dateOperatorOptions =
  DateOperatorOptions'
    { _dooOperatorName = Nothing
    , _dooLessThanOperatorName = Nothing
    , _dooGreaterThanOperatorName = Nothing
    }


-- | Indicates the actual string required in the query in order to isolate
-- the date property. For example, suppose an issue tracking schema object
-- has a property named *closeDate* that specifies an operator with an
-- operatorName of *closedon*. For searches on that data, queries like
-- *closedon:\<value>* will show results only where the value of the
-- *closeDate* property matches *\<value>*. By contrast, a search that uses
-- the same *\<value>* without an operator will return all items where
-- *\<value>* matches the value of any String properties or text within the
-- content field for the indexed datasource. The operator name can only
-- contain lowercase letters (a-z). The maximum length is 32 characters.
dooOperatorName :: Lens' DateOperatorOptions (Maybe Text)
dooOperatorName
  = lens _dooOperatorName
      (\ s a -> s{_dooOperatorName = a})

-- | Indicates the operator name required in the query in order to isolate
-- the date property using the less-than operator. For example, if
-- lessThanOperatorName is *closedbefore* and the property\'s name is
-- *closeDate*, then queries like *closedbefore:\<value>* will show results
-- only where the value of the property named *closeDate* is earlier than
-- *\<value>*. The operator name can only contain lowercase letters (a-z).
-- The maximum length is 32 characters.
dooLessThanOperatorName :: Lens' DateOperatorOptions (Maybe Text)
dooLessThanOperatorName
  = lens _dooLessThanOperatorName
      (\ s a -> s{_dooLessThanOperatorName = a})

-- | Indicates the operator name required in the query in order to isolate
-- the date property using the greater-than operator. For example, if
-- greaterThanOperatorName is *closedafter* and the property\'s name is
-- *closeDate*, then queries like *closedafter:\<value>* will show results
-- only where the value of the property named *closeDate* is later than
-- *\<value>*. The operator name can only contain lowercase letters (a-z).
-- The maximum length is 32 characters.
dooGreaterThanOperatorName :: Lens' DateOperatorOptions (Maybe Text)
dooGreaterThanOperatorName
  = lens _dooGreaterThanOperatorName
      (\ s a -> s{_dooGreaterThanOperatorName = a})

instance FromJSON DateOperatorOptions where
        parseJSON
          = withObject "DateOperatorOptions"
              (\ o ->
                 DateOperatorOptions' <$>
                   (o .:? "operatorName") <*>
                     (o .:? "lessThanOperatorName")
                     <*> (o .:? "greaterThanOperatorName"))

instance ToJSON DateOperatorOptions where
        toJSON DateOperatorOptions'{..}
          = object
              (catMaybes
                 [("operatorName" .=) <$> _dooOperatorName,
                  ("lessThanOperatorName" .=) <$>
                    _dooLessThanOperatorName,
                  ("greaterThanOperatorName" .=) <$>
                    _dooGreaterThanOperatorName])

--
-- /See:/ 'getDataSourceIndexStatsResponse' smart constructor.
newtype GetDataSourceIndexStatsResponse =
  GetDataSourceIndexStatsResponse'
    { _gdsisrStats :: Maybe [DataSourceIndexStats]
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'GetDataSourceIndexStatsResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'gdsisrStats'
getDataSourceIndexStatsResponse
    :: GetDataSourceIndexStatsResponse
getDataSourceIndexStatsResponse =
  GetDataSourceIndexStatsResponse' {_gdsisrStats = Nothing}


-- | Summary of indexed item counts, one for each day in the requested range.
gdsisrStats :: Lens' GetDataSourceIndexStatsResponse [DataSourceIndexStats]
gdsisrStats
  = lens _gdsisrStats (\ s a -> s{_gdsisrStats = a}) .
      _Default
      . _Coerce

instance FromJSON GetDataSourceIndexStatsResponse
         where
        parseJSON
          = withObject "GetDataSourceIndexStatsResponse"
              (\ o ->
                 GetDataSourceIndexStatsResponse' <$>
                   (o .:? "stats" .!= mempty))

instance ToJSON GetDataSourceIndexStatsResponse where
        toJSON GetDataSourceIndexStatsResponse'{..}
          = object (catMaybes [("stats" .=) <$> _gdsisrStats])

-- | The display options for an object.
--
-- /See:/ 'objectDisplayOptions' smart constructor.
data ObjectDisplayOptions =
  ObjectDisplayOptions'
    { _odoMetalines          :: !(Maybe [Metaline])
    , _odoObjectDisplayLabel :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ObjectDisplayOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'odoMetalines'
--
-- * 'odoObjectDisplayLabel'
objectDisplayOptions
    :: ObjectDisplayOptions
objectDisplayOptions =
  ObjectDisplayOptions'
    {_odoMetalines = Nothing, _odoObjectDisplayLabel = Nothing}


-- | Defines the properties that will be displayed in the metalines of the
-- search results. The property values will be displayed in the order given
-- here. If a property holds multiple values, all of the values will be
-- diplayed before the next properties. For this reason, it is a good
-- practice to specify singular properties before repeated properties in
-- this list. All of the properties must set is_returnable to true. The
-- maximum number of metalines is 3.
odoMetalines :: Lens' ObjectDisplayOptions [Metaline]
odoMetalines
  = lens _odoMetalines (\ s a -> s{_odoMetalines = a})
      . _Default
      . _Coerce

-- | The user friendly label to display in the search result to inidicate the
-- type of the item. This is OPTIONAL; if not given, an object label will
-- not be displayed on the context line of the search results. The maximum
-- length is 32 characters.
odoObjectDisplayLabel :: Lens' ObjectDisplayOptions (Maybe Text)
odoObjectDisplayLabel
  = lens _odoObjectDisplayLabel
      (\ s a -> s{_odoObjectDisplayLabel = a})

instance FromJSON ObjectDisplayOptions where
        parseJSON
          = withObject "ObjectDisplayOptions"
              (\ o ->
                 ObjectDisplayOptions' <$>
                   (o .:? "metalines" .!= mempty) <*>
                     (o .:? "objectDisplayLabel"))

instance ToJSON ObjectDisplayOptions where
        toJSON ObjectDisplayOptions'{..}
          = object
              (catMaybes
                 [("metalines" .=) <$> _odoMetalines,
                  ("objectDisplayLabel" .=) <$>
                    _odoObjectDisplayLabel])

-- | Information relevant only to a query entry.
--
-- /See:/ 'queryItem' smart constructor.
newtype QueryItem =
  QueryItem'
    { _qiIsSynthetic :: Maybe Bool
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'QueryItem' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'qiIsSynthetic'
queryItem
    :: QueryItem
queryItem = QueryItem' {_qiIsSynthetic = Nothing}


-- | True if the text was generated by means other than a previous user
-- search.
qiIsSynthetic :: Lens' QueryItem (Maybe Bool)
qiIsSynthetic
  = lens _qiIsSynthetic
      (\ s a -> s{_qiIsSynthetic = a})

instance FromJSON QueryItem where
        parseJSON
          = withObject "QueryItem"
              (\ o -> QueryItem' <$> (o .:? "isSynthetic"))

instance ToJSON QueryItem where
        toJSON QueryItem'{..}
          = object
              (catMaybes [("isSynthetic" .=) <$> _qiIsSynthetic])

--
-- /See:/ 'listUnmAppedIdentitiesResponse' smart constructor.
data ListUnmAppedIdentitiesResponse =
  ListUnmAppedIdentitiesResponse'
    { _luairNextPageToken      :: !(Maybe Text)
    , _luairUnmAppedIdentities :: !(Maybe [UnmAppedIdentity])
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ListUnmAppedIdentitiesResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'luairNextPageToken'
--
-- * 'luairUnmAppedIdentities'
listUnmAppedIdentitiesResponse
    :: ListUnmAppedIdentitiesResponse
listUnmAppedIdentitiesResponse =
  ListUnmAppedIdentitiesResponse'
    {_luairNextPageToken = Nothing, _luairUnmAppedIdentities = Nothing}


-- | Token to retrieve the next page of results, or empty if there are no
-- more results in the list.
luairNextPageToken :: Lens' ListUnmAppedIdentitiesResponse (Maybe Text)
luairNextPageToken
  = lens _luairNextPageToken
      (\ s a -> s{_luairNextPageToken = a})

luairUnmAppedIdentities :: Lens' ListUnmAppedIdentitiesResponse [UnmAppedIdentity]
luairUnmAppedIdentities
  = lens _luairUnmAppedIdentities
      (\ s a -> s{_luairUnmAppedIdentities = a})
      . _Default
      . _Coerce

instance FromJSON ListUnmAppedIdentitiesResponse
         where
        parseJSON
          = withObject "ListUnmAppedIdentitiesResponse"
              (\ o ->
                 ListUnmAppedIdentitiesResponse' <$>
                   (o .:? "nextPageToken") <*>
                     (o .:? "unmappedIdentities" .!= mempty))

instance ToJSON ListUnmAppedIdentitiesResponse where
        toJSON ListUnmAppedIdentitiesResponse'{..}
          = object
              (catMaybes
                 [("nextPageToken" .=) <$> _luairNextPageToken,
                  ("unmappedIdentities" .=) <$>
                    _luairUnmAppedIdentities])

--
-- /See:/ 'deleteQueueItemsRequest' smart constructor.
data DeleteQueueItemsRequest =
  DeleteQueueItemsRequest'
    { _dqirQueue         :: !(Maybe Text)
    , _dqirDebugOptions  :: !(Maybe DebugOptions)
    , _dqirConnectorName :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'DeleteQueueItemsRequest' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'dqirQueue'
--
-- * 'dqirDebugOptions'
--
-- * 'dqirConnectorName'
deleteQueueItemsRequest
    :: DeleteQueueItemsRequest
deleteQueueItemsRequest =
  DeleteQueueItemsRequest'
    { _dqirQueue = Nothing
    , _dqirDebugOptions = Nothing
    , _dqirConnectorName = Nothing
    }


-- | Name of a queue to delete items from.
dqirQueue :: Lens' DeleteQueueItemsRequest (Maybe Text)
dqirQueue
  = lens _dqirQueue (\ s a -> s{_dqirQueue = a})

-- | Common debug options.
dqirDebugOptions :: Lens' DeleteQueueItemsRequest (Maybe DebugOptions)
dqirDebugOptions
  = lens _dqirDebugOptions
      (\ s a -> s{_dqirDebugOptions = a})

-- | Name of connector making this call.
-- Format: datasources\/{source_id}\/connectors\/{ID}
dqirConnectorName :: Lens' DeleteQueueItemsRequest (Maybe Text)
dqirConnectorName
  = lens _dqirConnectorName
      (\ s a -> s{_dqirConnectorName = a})

instance FromJSON DeleteQueueItemsRequest where
        parseJSON
          = withObject "DeleteQueueItemsRequest"
              (\ o ->
                 DeleteQueueItemsRequest' <$>
                   (o .:? "queue") <*> (o .:? "debugOptions") <*>
                     (o .:? "connectorName"))

instance ToJSON DeleteQueueItemsRequest where
        toJSON DeleteQueueItemsRequest'{..}
          = object
              (catMaybes
                 [("queue" .=) <$> _dqirQueue,
                  ("debugOptions" .=) <$> _dqirDebugOptions,
                  ("connectorName" .=) <$> _dqirConnectorName])

-- | Results containing indexed information for a document.
--
-- /See:/ 'searchResult' smart constructor.
data SearchResult =
  SearchResult'
    { _srDebugInfo        :: !(Maybe ResultDebugInfo)
    , _srSnippet          :: !(Maybe Snippet)
    , _srURL              :: !(Maybe Text)
    , _srClusteredResults :: !(Maybe [SearchResult])
    , _srMetadata         :: !(Maybe Metadata)
    , _srTitle            :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'SearchResult' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'srDebugInfo'
--
-- * 'srSnippet'
--
-- * 'srURL'
--
-- * 'srClusteredResults'
--
-- * 'srMetadata'
--
-- * 'srTitle'
searchResult
    :: SearchResult
searchResult =
  SearchResult'
    { _srDebugInfo = Nothing
    , _srSnippet = Nothing
    , _srURL = Nothing
    , _srClusteredResults = Nothing
    , _srMetadata = Nothing
    , _srTitle = Nothing
    }


-- | Debugging information about this search result.
srDebugInfo :: Lens' SearchResult (Maybe ResultDebugInfo)
srDebugInfo
  = lens _srDebugInfo (\ s a -> s{_srDebugInfo = a})

-- | The concatenation of all snippets (summaries) available for this result.
srSnippet :: Lens' SearchResult (Maybe Snippet)
srSnippet
  = lens _srSnippet (\ s a -> s{_srSnippet = a})

-- | The URL of the search result. The URL contains a Google redirect to the
-- actual item. This URL is signed and shouldn\'t be changed.
srURL :: Lens' SearchResult (Maybe Text)
srURL = lens _srURL (\ s a -> s{_srURL = a})

-- | If source is clustered, provide list of clustered results. There will
-- only be one level of clustered results. If current source is not enabled
-- for clustering, this field will be empty.
srClusteredResults :: Lens' SearchResult [SearchResult]
srClusteredResults
  = lens _srClusteredResults
      (\ s a -> s{_srClusteredResults = a})
      . _Default
      . _Coerce

-- | Metadata of the search result.
srMetadata :: Lens' SearchResult (Maybe Metadata)
srMetadata
  = lens _srMetadata (\ s a -> s{_srMetadata = a})

-- | Title of the search result.
srTitle :: Lens' SearchResult (Maybe Text)
srTitle = lens _srTitle (\ s a -> s{_srTitle = a})

instance FromJSON SearchResult where
        parseJSON
          = withObject "SearchResult"
              (\ o ->
                 SearchResult' <$>
                   (o .:? "debugInfo") <*> (o .:? "snippet") <*>
                     (o .:? "url")
                     <*> (o .:? "clusteredResults" .!= mempty)
                     <*> (o .:? "metadata")
                     <*> (o .:? "title"))

instance ToJSON SearchResult where
        toJSON SearchResult'{..}
          = object
              (catMaybes
                 [("debugInfo" .=) <$> _srDebugInfo,
                  ("snippet" .=) <$> _srSnippet, ("url" .=) <$> _srURL,
                  ("clusteredResults" .=) <$> _srClusteredResults,
                  ("metadata" .=) <$> _srMetadata,
                  ("title" .=) <$> _srTitle])

--
-- /See:/ 'spellResult' smart constructor.
newtype SpellResult =
  SpellResult'
    { _srSuggestedQuery :: Maybe Text
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'SpellResult' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'srSuggestedQuery'
spellResult
    :: SpellResult
spellResult = SpellResult' {_srSuggestedQuery = Nothing}


-- | The suggested spelling of the query.
srSuggestedQuery :: Lens' SpellResult (Maybe Text)
srSuggestedQuery
  = lens _srSuggestedQuery
      (\ s a -> s{_srSuggestedQuery = a})

instance FromJSON SpellResult where
        parseJSON
          = withObject "SpellResult"
              (\ o -> SpellResult' <$> (o .:? "suggestedQuery"))

instance ToJSON SpellResult where
        toJSON SpellResult'{..}
          = object
              (catMaybes
                 [("suggestedQuery" .=) <$> _srSuggestedQuery])

-- | This field contains information about the person being suggested.
--
-- /See:/ 'peopleSuggestion' smart constructor.
newtype PeopleSuggestion =
  PeopleSuggestion'
    { _psPerson :: Maybe Person
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'PeopleSuggestion' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'psPerson'
peopleSuggestion
    :: PeopleSuggestion
peopleSuggestion = PeopleSuggestion' {_psPerson = Nothing}


-- | Suggested person. All fields of the person object might not be
-- populated.
psPerson :: Lens' PeopleSuggestion (Maybe Person)
psPerson = lens _psPerson (\ s a -> s{_psPerson = a})

instance FromJSON PeopleSuggestion where
        parseJSON
          = withObject "PeopleSuggestion"
              (\ o -> PeopleSuggestion' <$> (o .:? "person"))

instance ToJSON PeopleSuggestion where
        toJSON PeopleSuggestion'{..}
          = object (catMaybes [("person" .=) <$> _psPerson])

-- | List of sources that the user can search using the query API.
--
-- /See:/ 'querySource' smart constructor.
data QuerySource =
  QuerySource'
    { _qsShortName   :: !(Maybe Text)
    , _qsDisplayName :: !(Maybe Text)
    , _qsSource      :: !(Maybe Source)
    , _qsOperators   :: !(Maybe [QueryOperator])
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'QuerySource' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'qsShortName'
--
-- * 'qsDisplayName'
--
-- * 'qsSource'
--
-- * 'qsOperators'
querySource
    :: QuerySource
querySource =
  QuerySource'
    { _qsShortName = Nothing
    , _qsDisplayName = Nothing
    , _qsSource = Nothing
    , _qsOperators = Nothing
    }


-- | A short name or alias for the source. This value can be used with the
-- \'source\' operator.
qsShortName :: Lens' QuerySource (Maybe Text)
qsShortName
  = lens _qsShortName (\ s a -> s{_qsShortName = a})

-- | Display name of the data source.
qsDisplayName :: Lens' QuerySource (Maybe Text)
qsDisplayName
  = lens _qsDisplayName
      (\ s a -> s{_qsDisplayName = a})

-- | Name of the source
qsSource :: Lens' QuerySource (Maybe Source)
qsSource = lens _qsSource (\ s a -> s{_qsSource = a})

-- | List of all operators applicable for this source.
qsOperators :: Lens' QuerySource [QueryOperator]
qsOperators
  = lens _qsOperators (\ s a -> s{_qsOperators = a}) .
      _Default
      . _Coerce

instance FromJSON QuerySource where
        parseJSON
          = withObject "QuerySource"
              (\ o ->
                 QuerySource' <$>
                   (o .:? "shortName") <*> (o .:? "displayName") <*>
                     (o .:? "source")
                     <*> (o .:? "operators" .!= mempty))

instance ToJSON QuerySource where
        toJSON QuerySource'{..}
          = object
              (catMaybes
                 [("shortName" .=) <$> _qsShortName,
                  ("displayName" .=) <$> _qsDisplayName,
                  ("source" .=) <$> _qsSource,
                  ("operators" .=) <$> _qsOperators])

-- | Response of the suggest API.
--
-- /See:/ 'suggestResponse' smart constructor.
newtype SuggestResponse =
  SuggestResponse'
    { _srSuggestResults :: Maybe [SuggestResult]
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'SuggestResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'srSuggestResults'
suggestResponse
    :: SuggestResponse
suggestResponse = SuggestResponse' {_srSuggestResults = Nothing}


-- | List of suggestions.
srSuggestResults :: Lens' SuggestResponse [SuggestResult]
srSuggestResults
  = lens _srSuggestResults
      (\ s a -> s{_srSuggestResults = a})
      . _Default
      . _Coerce

instance FromJSON SuggestResponse where
        parseJSON
          = withObject "SuggestResponse"
              (\ o ->
                 SuggestResponse' <$>
                   (o .:? "suggestResults" .!= mempty))

instance ToJSON SuggestResponse where
        toJSON SuggestResponse'{..}
          = object
              (catMaybes
                 [("suggestResults" .=) <$> _srSuggestResults])

-- | Errors when the connector is communicating to the source repository.
--
-- /See:/ 'repositoryError' smart constructor.
data RepositoryError =
  RepositoryError'
    { _reHTTPStatusCode :: !(Maybe (Textual Int32))
    , _reType           :: !(Maybe RepositoryErrorType)
    , _reErrorMessage   :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'RepositoryError' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'reHTTPStatusCode'
--
-- * 'reType'
--
-- * 'reErrorMessage'
repositoryError
    :: RepositoryError
repositoryError =
  RepositoryError'
    {_reHTTPStatusCode = Nothing, _reType = Nothing, _reErrorMessage = Nothing}


-- | Error codes. Matches the definition of HTTP status codes.
reHTTPStatusCode :: Lens' RepositoryError (Maybe Int32)
reHTTPStatusCode
  = lens _reHTTPStatusCode
      (\ s a -> s{_reHTTPStatusCode = a})
      . mapping _Coerce

-- | Type of error.
reType :: Lens' RepositoryError (Maybe RepositoryErrorType)
reType = lens _reType (\ s a -> s{_reType = a})

-- | Message that describes the error. The maximum allowable length of the
-- message is 8192 characters.
reErrorMessage :: Lens' RepositoryError (Maybe Text)
reErrorMessage
  = lens _reErrorMessage
      (\ s a -> s{_reErrorMessage = a})

instance FromJSON RepositoryError where
        parseJSON
          = withObject "RepositoryError"
              (\ o ->
                 RepositoryError' <$>
                   (o .:? "httpStatusCode") <*> (o .:? "type") <*>
                     (o .:? "errorMessage"))

instance ToJSON RepositoryError where
        toJSON RepositoryError'{..}
          = object
              (catMaybes
                 [("httpStatusCode" .=) <$> _reHTTPStatusCode,
                  ("type" .=) <$> _reType,
                  ("errorMessage" .=) <$> _reErrorMessage])

-- | Options for html properties.
--
-- /See:/ 'htmlPropertyOptions' smart constructor.
data HTMLPropertyOptions =
  HTMLPropertyOptions'
    { _hpoRetrievalImportance :: !(Maybe RetrievalImportance)
    , _hpoOperatorOptions     :: !(Maybe HTMLOperatorOptions)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'HTMLPropertyOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'hpoRetrievalImportance'
--
-- * 'hpoOperatorOptions'
htmlPropertyOptions
    :: HTMLPropertyOptions
htmlPropertyOptions =
  HTMLPropertyOptions'
    {_hpoRetrievalImportance = Nothing, _hpoOperatorOptions = Nothing}


-- | Indicates the search quality importance of the tokens within the field
-- when used for retrieval. Can only be set to DEFAULT or NONE.
hpoRetrievalImportance :: Lens' HTMLPropertyOptions (Maybe RetrievalImportance)
hpoRetrievalImportance
  = lens _hpoRetrievalImportance
      (\ s a -> s{_hpoRetrievalImportance = a})

-- | If set, describes how the property should be used as a search operator.
hpoOperatorOptions :: Lens' HTMLPropertyOptions (Maybe HTMLOperatorOptions)
hpoOperatorOptions
  = lens _hpoOperatorOptions
      (\ s a -> s{_hpoOperatorOptions = a})

instance FromJSON HTMLPropertyOptions where
        parseJSON
          = withObject "HTMLPropertyOptions"
              (\ o ->
                 HTMLPropertyOptions' <$>
                   (o .:? "retrievalImportance") <*>
                     (o .:? "operatorOptions"))

instance ToJSON HTMLPropertyOptions where
        toJSON HTMLPropertyOptions'{..}
          = object
              (catMaybes
                 [("retrievalImportance" .=) <$>
                    _hpoRetrievalImportance,
                  ("operatorOptions" .=) <$> _hpoOperatorOptions])

-- | The definition of a property within an object.
--
-- /See:/ 'propertyDefinition' smart constructor.
data PropertyDefinition =
  PropertyDefinition'
    { _pdEnumPropertyOptions      :: !(Maybe EnumPropertyOptions)
    , _pdHTMLPropertyOptions      :: !(Maybe HTMLPropertyOptions)
    , _pdObjectPropertyOptions    :: !(Maybe ObjectPropertyOptions)
    , _pdIsReturnable             :: !(Maybe Bool)
    , _pdTimestampPropertyOptions :: !(Maybe TimestampPropertyOptions)
    , _pdIntegerPropertyOptions   :: !(Maybe IntegerPropertyOptions)
    , _pdName                     :: !(Maybe Text)
    , _pdIsRepeatable             :: !(Maybe Bool)
    , _pdDoublePropertyOptions    :: !(Maybe DoublePropertyOptions)
    , _pdDisplayOptions           :: !(Maybe PropertyDisplayOptions)
    , _pdTextPropertyOptions      :: !(Maybe TextPropertyOptions)
    , _pdIsSortable               :: !(Maybe Bool)
    , _pdIsFacetable              :: !(Maybe Bool)
    , _pdBooleanPropertyOptions   :: !(Maybe BooleanPropertyOptions)
    , _pdDatePropertyOptions      :: !(Maybe DatePropertyOptions)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'PropertyDefinition' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'pdEnumPropertyOptions'
--
-- * 'pdHTMLPropertyOptions'
--
-- * 'pdObjectPropertyOptions'
--
-- * 'pdIsReturnable'
--
-- * 'pdTimestampPropertyOptions'
--
-- * 'pdIntegerPropertyOptions'
--
-- * 'pdName'
--
-- * 'pdIsRepeatable'
--
-- * 'pdDoublePropertyOptions'
--
-- * 'pdDisplayOptions'
--
-- * 'pdTextPropertyOptions'
--
-- * 'pdIsSortable'
--
-- * 'pdIsFacetable'
--
-- * 'pdBooleanPropertyOptions'
--
-- * 'pdDatePropertyOptions'
propertyDefinition
    :: PropertyDefinition
propertyDefinition =
  PropertyDefinition'
    { _pdEnumPropertyOptions = Nothing
    , _pdHTMLPropertyOptions = Nothing
    , _pdObjectPropertyOptions = Nothing
    , _pdIsReturnable = Nothing
    , _pdTimestampPropertyOptions = Nothing
    , _pdIntegerPropertyOptions = Nothing
    , _pdName = Nothing
    , _pdIsRepeatable = Nothing
    , _pdDoublePropertyOptions = Nothing
    , _pdDisplayOptions = Nothing
    , _pdTextPropertyOptions = Nothing
    , _pdIsSortable = Nothing
    , _pdIsFacetable = Nothing
    , _pdBooleanPropertyOptions = Nothing
    , _pdDatePropertyOptions = Nothing
    }


pdEnumPropertyOptions :: Lens' PropertyDefinition (Maybe EnumPropertyOptions)
pdEnumPropertyOptions
  = lens _pdEnumPropertyOptions
      (\ s a -> s{_pdEnumPropertyOptions = a})

pdHTMLPropertyOptions :: Lens' PropertyDefinition (Maybe HTMLPropertyOptions)
pdHTMLPropertyOptions
  = lens _pdHTMLPropertyOptions
      (\ s a -> s{_pdHTMLPropertyOptions = a})

pdObjectPropertyOptions :: Lens' PropertyDefinition (Maybe ObjectPropertyOptions)
pdObjectPropertyOptions
  = lens _pdObjectPropertyOptions
      (\ s a -> s{_pdObjectPropertyOptions = a})

-- | Indicates that the property identifies data that should be returned in
-- search results via the Query API. If set to *true*, indicates that Query
-- API users can use matching property fields in results. However, storing
-- fields requires more space allocation and uses more bandwidth for search
-- queries, which impacts performance over large datasets. Set to *true*
-- here only if the field is needed for search results. Cannot be true for
-- properties whose type is an object.
pdIsReturnable :: Lens' PropertyDefinition (Maybe Bool)
pdIsReturnable
  = lens _pdIsReturnable
      (\ s a -> s{_pdIsReturnable = a})

pdTimestampPropertyOptions :: Lens' PropertyDefinition (Maybe TimestampPropertyOptions)
pdTimestampPropertyOptions
  = lens _pdTimestampPropertyOptions
      (\ s a -> s{_pdTimestampPropertyOptions = a})

pdIntegerPropertyOptions :: Lens' PropertyDefinition (Maybe IntegerPropertyOptions)
pdIntegerPropertyOptions
  = lens _pdIntegerPropertyOptions
      (\ s a -> s{_pdIntegerPropertyOptions = a})

-- | The name of the property. Item indexing requests sent to the Indexing
-- API should set the property name equal to this value. For example, if
-- name is *subject_line*, then indexing requests for document items with
-- subject fields should set the name for that field equal to
-- *subject_line*. Use the name as the identifier for the object property.
-- Once registered as a property for an object, you cannot re-use this name
-- for another property within that object. The name must start with a
-- letter and can only contain letters (A-Z, a-z) or numbers (0-9). The
-- maximum length is 256 characters.
pdName :: Lens' PropertyDefinition (Maybe Text)
pdName = lens _pdName (\ s a -> s{_pdName = a})

-- | Indicates that multiple values are allowed for the property. For
-- example, a document only has one description but can have multiple
-- comments. Cannot be true for properties whose type is a boolean. If set
-- to false, properties that contain more than one value will cause the
-- indexing request for that item to be rejected.
pdIsRepeatable :: Lens' PropertyDefinition (Maybe Bool)
pdIsRepeatable
  = lens _pdIsRepeatable
      (\ s a -> s{_pdIsRepeatable = a})

pdDoublePropertyOptions :: Lens' PropertyDefinition (Maybe DoublePropertyOptions)
pdDoublePropertyOptions
  = lens _pdDoublePropertyOptions
      (\ s a -> s{_pdDoublePropertyOptions = a})

-- | Options that determine how the property is displayed in the Cloud Search
-- results page if it is specified to be displayed in the object\'s display
-- options .
pdDisplayOptions :: Lens' PropertyDefinition (Maybe PropertyDisplayOptions)
pdDisplayOptions
  = lens _pdDisplayOptions
      (\ s a -> s{_pdDisplayOptions = a})

pdTextPropertyOptions :: Lens' PropertyDefinition (Maybe TextPropertyOptions)
pdTextPropertyOptions
  = lens _pdTextPropertyOptions
      (\ s a -> s{_pdTextPropertyOptions = a})

-- | Indicates that the property can be used for sorting. Cannot be true for
-- properties that are repeatable. Cannot be true for properties whose type
-- is object or user identifier. IsReturnable must be true to set this
-- option. Only supported for Boolean, Date, Double, Integer, and Timestamp
-- properties.
pdIsSortable :: Lens' PropertyDefinition (Maybe Bool)
pdIsSortable
  = lens _pdIsSortable (\ s a -> s{_pdIsSortable = a})

-- | Indicates that the property can be used for generating facets. Cannot be
-- true for properties whose type is object. IsReturnable must be true to
-- set this option. Only supported for Boolean, Enum, and Text properties.
pdIsFacetable :: Lens' PropertyDefinition (Maybe Bool)
pdIsFacetable
  = lens _pdIsFacetable
      (\ s a -> s{_pdIsFacetable = a})

pdBooleanPropertyOptions :: Lens' PropertyDefinition (Maybe BooleanPropertyOptions)
pdBooleanPropertyOptions
  = lens _pdBooleanPropertyOptions
      (\ s a -> s{_pdBooleanPropertyOptions = a})

pdDatePropertyOptions :: Lens' PropertyDefinition (Maybe DatePropertyOptions)
pdDatePropertyOptions
  = lens _pdDatePropertyOptions
      (\ s a -> s{_pdDatePropertyOptions = a})

instance FromJSON PropertyDefinition where
        parseJSON
          = withObject "PropertyDefinition"
              (\ o ->
                 PropertyDefinition' <$>
                   (o .:? "enumPropertyOptions") <*>
                     (o .:? "htmlPropertyOptions")
                     <*> (o .:? "objectPropertyOptions")
                     <*> (o .:? "isReturnable")
                     <*> (o .:? "timestampPropertyOptions")
                     <*> (o .:? "integerPropertyOptions")
                     <*> (o .:? "name")
                     <*> (o .:? "isRepeatable")
                     <*> (o .:? "doublePropertyOptions")
                     <*> (o .:? "displayOptions")
                     <*> (o .:? "textPropertyOptions")
                     <*> (o .:? "isSortable")
                     <*> (o .:? "isFacetable")
                     <*> (o .:? "booleanPropertyOptions")
                     <*> (o .:? "datePropertyOptions"))

instance ToJSON PropertyDefinition where
        toJSON PropertyDefinition'{..}
          = object
              (catMaybes
                 [("enumPropertyOptions" .=) <$>
                    _pdEnumPropertyOptions,
                  ("htmlPropertyOptions" .=) <$>
                    _pdHTMLPropertyOptions,
                  ("objectPropertyOptions" .=) <$>
                    _pdObjectPropertyOptions,
                  ("isReturnable" .=) <$> _pdIsReturnable,
                  ("timestampPropertyOptions" .=) <$>
                    _pdTimestampPropertyOptions,
                  ("integerPropertyOptions" .=) <$>
                    _pdIntegerPropertyOptions,
                  ("name" .=) <$> _pdName,
                  ("isRepeatable" .=) <$> _pdIsRepeatable,
                  ("doublePropertyOptions" .=) <$>
                    _pdDoublePropertyOptions,
                  ("displayOptions" .=) <$> _pdDisplayOptions,
                  ("textPropertyOptions" .=) <$>
                    _pdTextPropertyOptions,
                  ("isSortable" .=) <$> _pdIsSortable,
                  ("isFacetable" .=) <$> _pdIsFacetable,
                  ("booleanPropertyOptions" .=) <$>
                    _pdBooleanPropertyOptions,
                  ("datePropertyOptions" .=) <$>
                    _pdDatePropertyOptions])

--
-- /See:/ 'sortOptions' smart constructor.
data SortOptions =
  SortOptions'
    { _soSortOrder    :: !(Maybe SortOptionsSortOrder)
    , _soOperatorName :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'SortOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'soSortOrder'
--
-- * 'soOperatorName'
sortOptions
    :: SortOptions
sortOptions = SortOptions' {_soSortOrder = Nothing, _soOperatorName = Nothing}


-- | Ascending is the default sort order
soSortOrder :: Lens' SortOptions (Maybe SortOptionsSortOrder)
soSortOrder
  = lens _soSortOrder (\ s a -> s{_soSortOrder = a})

-- | Name of the operator corresponding to the field to sort on. The
-- corresponding property must be marked as sortable.
soOperatorName :: Lens' SortOptions (Maybe Text)
soOperatorName
  = lens _soOperatorName
      (\ s a -> s{_soOperatorName = a})

instance FromJSON SortOptions where
        parseJSON
          = withObject "SortOptions"
              (\ o ->
                 SortOptions' <$>
                   (o .:? "sortOrder") <*> (o .:? "operatorName"))

instance ToJSON SortOptions where
        toJSON SortOptions'{..}
          = object
              (catMaybes
                 [("sortOrder" .=) <$> _soSortOrder,
                  ("operatorName" .=) <$> _soOperatorName])

-- | Options for object properties.
--
-- /See:/ 'objectPropertyOptions' smart constructor.
newtype ObjectPropertyOptions =
  ObjectPropertyOptions'
    { _opoSubobjectProperties :: Maybe [PropertyDefinition]
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ObjectPropertyOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'opoSubobjectProperties'
objectPropertyOptions
    :: ObjectPropertyOptions
objectPropertyOptions =
  ObjectPropertyOptions' {_opoSubobjectProperties = Nothing}


-- | The properties of the sub-object. These properties represent a nested
-- object. For example, if this property represents a postal address, the
-- subobjectProperties might be named *street*, *city*, and *state*. The
-- maximum number of elements is 1000.
opoSubobjectProperties :: Lens' ObjectPropertyOptions [PropertyDefinition]
opoSubobjectProperties
  = lens _opoSubobjectProperties
      (\ s a -> s{_opoSubobjectProperties = a})
      . _Default
      . _Coerce

instance FromJSON ObjectPropertyOptions where
        parseJSON
          = withObject "ObjectPropertyOptions"
              (\ o ->
                 ObjectPropertyOptions' <$>
                   (o .:? "subobjectProperties" .!= mempty))

instance ToJSON ObjectPropertyOptions where
        toJSON ObjectPropertyOptions'{..}
          = object
              (catMaybes
                 [("subobjectProperties" .=) <$>
                    _opoSubobjectProperties])

-- | The search API response.
--
-- /See:/ 'searchResponse' smart constructor.
data SearchResponse =
  SearchResponse'
    { _sSpellResults        :: !(Maybe [SpellResult])
    , _sFacetResults        :: !(Maybe [FacetResult])
    , _sDebugInfo           :: !(Maybe ResponseDebugInfo)
    , _sResults             :: !(Maybe [SearchResult])
    , _sHasMoreResults      :: !(Maybe Bool)
    , _sResultCounts        :: !(Maybe ResultCounts)
    , _sResultCountExact    :: !(Maybe (Textual Int64))
    , _sResultCountEstimate :: !(Maybe (Textual Int64))
    , _sQueryInterpretation :: !(Maybe QueryInterpretation)
    , _sStructuredResults   :: !(Maybe [StructuredResult])
    , _sErrorInfo           :: !(Maybe ErrorInfo)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'SearchResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'sSpellResults'
--
-- * 'sFacetResults'
--
-- * 'sDebugInfo'
--
-- * 'sResults'
--
-- * 'sHasMoreResults'
--
-- * 'sResultCounts'
--
-- * 'sResultCountExact'
--
-- * 'sResultCountEstimate'
--
-- * 'sQueryInterpretation'
--
-- * 'sStructuredResults'
--
-- * 'sErrorInfo'
searchResponse
    :: SearchResponse
searchResponse =
  SearchResponse'
    { _sSpellResults = Nothing
    , _sFacetResults = Nothing
    , _sDebugInfo = Nothing
    , _sResults = Nothing
    , _sHasMoreResults = Nothing
    , _sResultCounts = Nothing
    , _sResultCountExact = Nothing
    , _sResultCountEstimate = Nothing
    , _sQueryInterpretation = Nothing
    , _sStructuredResults = Nothing
    , _sErrorInfo = Nothing
    }


-- | Suggested spelling for the query.
sSpellResults :: Lens' SearchResponse [SpellResult]
sSpellResults
  = lens _sSpellResults
      (\ s a -> s{_sSpellResults = a})
      . _Default
      . _Coerce

-- | Repeated facet results.
sFacetResults :: Lens' SearchResponse [FacetResult]
sFacetResults
  = lens _sFacetResults
      (\ s a -> s{_sFacetResults = a})
      . _Default
      . _Coerce

-- | Debugging information about the response.
sDebugInfo :: Lens' SearchResponse (Maybe ResponseDebugInfo)
sDebugInfo
  = lens _sDebugInfo (\ s a -> s{_sDebugInfo = a})

-- | Results from a search query.
sResults :: Lens' SearchResponse [SearchResult]
sResults
  = lens _sResults (\ s a -> s{_sResults = a}) .
      _Default
      . _Coerce

-- | Whether there are more search results matching the query.
sHasMoreResults :: Lens' SearchResponse (Maybe Bool)
sHasMoreResults
  = lens _sHasMoreResults
      (\ s a -> s{_sHasMoreResults = a})

-- | Expanded result count information.
sResultCounts :: Lens' SearchResponse (Maybe ResultCounts)
sResultCounts
  = lens _sResultCounts
      (\ s a -> s{_sResultCounts = a})

-- | The exact result count for this query.
sResultCountExact :: Lens' SearchResponse (Maybe Int64)
sResultCountExact
  = lens _sResultCountExact
      (\ s a -> s{_sResultCountExact = a})
      . mapping _Coerce

-- | The estimated result count for this query.
sResultCountEstimate :: Lens' SearchResponse (Maybe Int64)
sResultCountEstimate
  = lens _sResultCountEstimate
      (\ s a -> s{_sResultCountEstimate = a})
      . mapping _Coerce

-- | Query interpretation result for user query. Empty if query
-- interpretation is disabled.
sQueryInterpretation :: Lens' SearchResponse (Maybe QueryInterpretation)
sQueryInterpretation
  = lens _sQueryInterpretation
      (\ s a -> s{_sQueryInterpretation = a})

-- | Structured results for the user query. These results are not counted
-- against the page_size.
sStructuredResults :: Lens' SearchResponse [StructuredResult]
sStructuredResults
  = lens _sStructuredResults
      (\ s a -> s{_sStructuredResults = a})
      . _Default
      . _Coerce

-- | Error information about the response.
sErrorInfo :: Lens' SearchResponse (Maybe ErrorInfo)
sErrorInfo
  = lens _sErrorInfo (\ s a -> s{_sErrorInfo = a})

instance FromJSON SearchResponse where
        parseJSON
          = withObject "SearchResponse"
              (\ o ->
                 SearchResponse' <$>
                   (o .:? "spellResults" .!= mempty) <*>
                     (o .:? "facetResults" .!= mempty)
                     <*> (o .:? "debugInfo")
                     <*> (o .:? "results" .!= mempty)
                     <*> (o .:? "hasMoreResults")
                     <*> (o .:? "resultCounts")
                     <*> (o .:? "resultCountExact")
                     <*> (o .:? "resultCountEstimate")
                     <*> (o .:? "queryInterpretation")
                     <*> (o .:? "structuredResults" .!= mempty)
                     <*> (o .:? "errorInfo"))

instance ToJSON SearchResponse where
        toJSON SearchResponse'{..}
          = object
              (catMaybes
                 [("spellResults" .=) <$> _sSpellResults,
                  ("facetResults" .=) <$> _sFacetResults,
                  ("debugInfo" .=) <$> _sDebugInfo,
                  ("results" .=) <$> _sResults,
                  ("hasMoreResults" .=) <$> _sHasMoreResults,
                  ("resultCounts" .=) <$> _sResultCounts,
                  ("resultCountExact" .=) <$> _sResultCountExact,
                  ("resultCountEstimate" .=) <$> _sResultCountEstimate,
                  ("queryInterpretation" .=) <$> _sQueryInterpretation,
                  ("structuredResults" .=) <$> _sStructuredResults,
                  ("errorInfo" .=) <$> _sErrorInfo])

-- | One suggestion result.
--
-- /See:/ 'suggestResult' smart constructor.
data SuggestResult =
  SuggestResult'
    { _sPeopleSuggestion :: !(Maybe PeopleSuggestion)
    , _sQuerySuggestion  :: !(Maybe QuerySuggestion)
    , _sSuggestedQuery   :: !(Maybe Text)
    , _sSource           :: !(Maybe Source)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'SuggestResult' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'sPeopleSuggestion'
--
-- * 'sQuerySuggestion'
--
-- * 'sSuggestedQuery'
--
-- * 'sSource'
suggestResult
    :: SuggestResult
suggestResult =
  SuggestResult'
    { _sPeopleSuggestion = Nothing
    , _sQuerySuggestion = Nothing
    , _sSuggestedQuery = Nothing
    , _sSource = Nothing
    }


-- | This is present when the suggestion indicates a person. It contains more
-- information about the person - like their email ID, name etc.
sPeopleSuggestion :: Lens' SuggestResult (Maybe PeopleSuggestion)
sPeopleSuggestion
  = lens _sPeopleSuggestion
      (\ s a -> s{_sPeopleSuggestion = a})

-- | This field will be present if the suggested query is a word\/phrase
-- completion.
sQuerySuggestion :: Lens' SuggestResult (Maybe QuerySuggestion)
sQuerySuggestion
  = lens _sQuerySuggestion
      (\ s a -> s{_sQuerySuggestion = a})

-- | The suggested query that will be used for search, when the user clicks
-- on the suggestion
sSuggestedQuery :: Lens' SuggestResult (Maybe Text)
sSuggestedQuery
  = lens _sSuggestedQuery
      (\ s a -> s{_sSuggestedQuery = a})

-- | The source of the suggestion.
sSource :: Lens' SuggestResult (Maybe Source)
sSource = lens _sSource (\ s a -> s{_sSource = a})

instance FromJSON SuggestResult where
        parseJSON
          = withObject "SuggestResult"
              (\ o ->
                 SuggestResult' <$>
                   (o .:? "peopleSuggestion") <*>
                     (o .:? "querySuggestion")
                     <*> (o .:? "suggestedQuery")
                     <*> (o .:? "source"))

instance ToJSON SuggestResult where
        toJSON SuggestResult'{..}
          = object
              (catMaybes
                 [("peopleSuggestion" .=) <$> _sPeopleSuggestion,
                  ("querySuggestion" .=) <$> _sQuerySuggestion,
                  ("suggestedQuery" .=) <$> _sSuggestedQuery,
                  ("source" .=) <$> _sSource])

-- | List of text values.
--
-- /See:/ 'textValues' smart constructor.
newtype TextValues =
  TextValues'
    { _tvValues :: Maybe [Text]
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'TextValues' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'tvValues'
textValues
    :: TextValues
textValues = TextValues' {_tvValues = Nothing}


-- | The maximum allowable length for text values is 2048 characters.
tvValues :: Lens' TextValues [Text]
tvValues
  = lens _tvValues (\ s a -> s{_tvValues = a}) .
      _Default
      . _Coerce

instance FromJSON TextValues where
        parseJSON
          = withObject "TextValues"
              (\ o -> TextValues' <$> (o .:? "values" .!= mempty))

instance ToJSON TextValues where
        toJSON TextValues'{..}
          = object (catMaybes [("values" .=) <$> _tvValues])

-- | Drive location search restricts (e.g. \"is:starred\").
--
-- /See:/ 'driveLocationRestrict' smart constructor.
newtype DriveLocationRestrict =
  DriveLocationRestrict'
    { _dlrType :: Maybe DriveLocationRestrictType
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'DriveLocationRestrict' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'dlrType'
driveLocationRestrict
    :: DriveLocationRestrict
driveLocationRestrict = DriveLocationRestrict' {_dlrType = Nothing}


dlrType :: Lens' DriveLocationRestrict (Maybe DriveLocationRestrictType)
dlrType = lens _dlrType (\ s a -> s{_dlrType = a})

instance FromJSON DriveLocationRestrict where
        parseJSON
          = withObject "DriveLocationRestrict"
              (\ o -> DriveLocationRestrict' <$> (o .:? "type"))

instance ToJSON DriveLocationRestrict where
        toJSON DriveLocationRestrict'{..}
          = object (catMaybes [("type" .=) <$> _dlrType])

-- | List sources response.
--
-- /See:/ 'listQuerySourcesResponse' smart constructor.
data ListQuerySourcesResponse =
  ListQuerySourcesResponse'
    { _lqsrNextPageToken :: !(Maybe Text)
    , _lqsrSources       :: !(Maybe [QuerySource])
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ListQuerySourcesResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'lqsrNextPageToken'
--
-- * 'lqsrSources'
listQuerySourcesResponse
    :: ListQuerySourcesResponse
listQuerySourcesResponse =
  ListQuerySourcesResponse'
    {_lqsrNextPageToken = Nothing, _lqsrSources = Nothing}


lqsrNextPageToken :: Lens' ListQuerySourcesResponse (Maybe Text)
lqsrNextPageToken
  = lens _lqsrNextPageToken
      (\ s a -> s{_lqsrNextPageToken = a})

lqsrSources :: Lens' ListQuerySourcesResponse [QuerySource]
lqsrSources
  = lens _lqsrSources (\ s a -> s{_lqsrSources = a}) .
      _Default
      . _Coerce

instance FromJSON ListQuerySourcesResponse where
        parseJSON
          = withObject "ListQuerySourcesResponse"
              (\ o ->
                 ListQuerySourcesResponse' <$>
                   (o .:? "nextPageToken") <*>
                     (o .:? "sources" .!= mempty))

instance ToJSON ListQuerySourcesResponse where
        toJSON ListQuerySourcesResponse'{..}
          = object
              (catMaybes
                 [("nextPageToken" .=) <$> _lqsrNextPageToken,
                  ("sources" .=) <$> _lqsrSources])

-- | Used to provide a search operator for double properties. This is
-- optional. Search operators let users restrict the query to specific
-- fields relevant to the type of item being searched.
--
-- /See:/ 'doubleOperatorOptions' smart constructor.
newtype DoubleOperatorOptions =
  DoubleOperatorOptions'
    { _dOperatorName :: Maybe Text
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'DoubleOperatorOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'dOperatorName'
doubleOperatorOptions
    :: DoubleOperatorOptions
doubleOperatorOptions = DoubleOperatorOptions' {_dOperatorName = Nothing}


-- | Indicates the operator name required in the query in order to use the
-- double property in sorting or as a facet. The operator name can only
-- contain lowercase letters (a-z). The maximum length is 32 characters.
dOperatorName :: Lens' DoubleOperatorOptions (Maybe Text)
dOperatorName
  = lens _dOperatorName
      (\ s a -> s{_dOperatorName = a})

instance FromJSON DoubleOperatorOptions where
        parseJSON
          = withObject "DoubleOperatorOptions"
              (\ o ->
                 DoubleOperatorOptions' <$> (o .:? "operatorName"))

instance ToJSON DoubleOperatorOptions where
        toJSON DoubleOperatorOptions'{..}
          = object
              (catMaybes [("operatorName" .=) <$> _dOperatorName])

-- | This resource represents a long-running operation that is the result of
-- a network API call.
--
-- /See:/ 'operation' smart constructor.
data Operation =
  Operation'
    { _oDone     :: !(Maybe Bool)
    , _oError    :: !(Maybe Status)
    , _oResponse :: !(Maybe OperationResponse)
    , _oName     :: !(Maybe Text)
    , _oMetadata :: !(Maybe OperationMetadata)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'Operation' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'oDone'
--
-- * 'oError'
--
-- * 'oResponse'
--
-- * 'oName'
--
-- * 'oMetadata'
operation
    :: Operation
operation =
  Operation'
    { _oDone = Nothing
    , _oError = Nothing
    , _oResponse = Nothing
    , _oName = Nothing
    , _oMetadata = Nothing
    }


-- | If the value is \`false\`, it means the operation is still in progress.
-- If \`true\`, the operation is completed, and either \`error\` or
-- \`response\` is available.
oDone :: Lens' Operation (Maybe Bool)
oDone = lens _oDone (\ s a -> s{_oDone = a})

-- | The error result of the operation in case of failure or cancellation.
oError :: Lens' Operation (Maybe Status)
oError = lens _oError (\ s a -> s{_oError = a})

-- | The normal response of the operation in case of success. If the original
-- method returns no data on success, such as \`Delete\`, the response is
-- \`google.protobuf.Empty\`. If the original method is standard
-- \`Get\`\/\`Create\`\/\`Update\`, the response should be the resource.
-- For other methods, the response should have the type \`XxxResponse\`,
-- where \`Xxx\` is the original method name. For example, if the original
-- method name is \`TakeSnapshot()\`, the inferred response type is
-- \`TakeSnapshotResponse\`.
oResponse :: Lens' Operation (Maybe OperationResponse)
oResponse
  = lens _oResponse (\ s a -> s{_oResponse = a})

-- | The server-assigned name, which is only unique within the same service
-- that originally returns it. If you use the default HTTP mapping, the
-- \`name\` should have the format of \`operations\/some\/unique\/name\`.
oName :: Lens' Operation (Maybe Text)
oName = lens _oName (\ s a -> s{_oName = a})

-- | Service-specific metadata associated with the operation. It typically
-- contains progress information and common metadata such as create time.
-- Some services might not provide such metadata. Any method that returns a
-- long-running operation should document the metadata type, if any.
oMetadata :: Lens' Operation (Maybe OperationMetadata)
oMetadata
  = lens _oMetadata (\ s a -> s{_oMetadata = a})

instance FromJSON Operation where
        parseJSON
          = withObject "Operation"
              (\ o ->
                 Operation' <$>
                   (o .:? "done") <*> (o .:? "error") <*>
                     (o .:? "response")
                     <*> (o .:? "name")
                     <*> (o .:? "metadata"))

instance ToJSON Operation where
        toJSON Operation'{..}
          = object
              (catMaybes
                 [("done" .=) <$> _oDone, ("error" .=) <$> _oError,
                  ("response" .=) <$> _oResponse,
                  ("name" .=) <$> _oName,
                  ("metadata" .=) <$> _oMetadata])

-- | Object to represent a person.
--
-- /See:/ 'person' smart constructor.
data Person =
  Person'
    { _pEmailAddresses :: !(Maybe [EmailAddress])
    , _pPersonNames    :: !(Maybe [Name])
    , _pPhotos         :: !(Maybe [Photo])
    , _pName           :: !(Maybe Text)
    , _pObfuscatedId   :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'Person' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'pEmailAddresses'
--
-- * 'pPersonNames'
--
-- * 'pPhotos'
--
-- * 'pName'
--
-- * 'pObfuscatedId'
person
    :: Person
person =
  Person'
    { _pEmailAddresses = Nothing
    , _pPersonNames = Nothing
    , _pPhotos = Nothing
    , _pName = Nothing
    , _pObfuscatedId = Nothing
    }


-- | The person\'s email addresses
pEmailAddresses :: Lens' Person [EmailAddress]
pEmailAddresses
  = lens _pEmailAddresses
      (\ s a -> s{_pEmailAddresses = a})
      . _Default
      . _Coerce

-- | The person\'s name
pPersonNames :: Lens' Person [Name]
pPersonNames
  = lens _pPersonNames (\ s a -> s{_pPersonNames = a})
      . _Default
      . _Coerce

-- | A person\'s read-only photo. A picture shown next to the person\'s name
-- to help others recognize the person in search results.
pPhotos :: Lens' Person [Photo]
pPhotos
  = lens _pPhotos (\ s a -> s{_pPhotos = a}) . _Default
      . _Coerce

-- | The resource name of the person to provide information about. See
-- <https://developers.google.com/people/api/rest/v1/people/get People.get>
-- from Google People API.
pName :: Lens' Person (Maybe Text)
pName = lens _pName (\ s a -> s{_pName = a})

-- | Obfuscated ID of a person.
pObfuscatedId :: Lens' Person (Maybe Text)
pObfuscatedId
  = lens _pObfuscatedId
      (\ s a -> s{_pObfuscatedId = a})

instance FromJSON Person where
        parseJSON
          = withObject "Person"
              (\ o ->
                 Person' <$>
                   (o .:? "emailAddresses" .!= mempty) <*>
                     (o .:? "personNames" .!= mempty)
                     <*> (o .:? "photos" .!= mempty)
                     <*> (o .:? "name")
                     <*> (o .:? "obfuscatedId"))

instance ToJSON Person where
        toJSON Person'{..}
          = object
              (catMaybes
                 [("emailAddresses" .=) <$> _pEmailAddresses,
                  ("personNames" .=) <$> _pPersonNames,
                  ("photos" .=) <$> _pPhotos, ("name" .=) <$> _pName,
                  ("obfuscatedId" .=) <$> _pObfuscatedId])

--
-- /See:/ 'compositeFilter' smart constructor.
data CompositeFilter =
  CompositeFilter'
    { _cfSubFilters    :: !(Maybe [Filter])
    , _cfLogicOperator :: !(Maybe CompositeFilterLogicOperator)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'CompositeFilter' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'cfSubFilters'
--
-- * 'cfLogicOperator'
compositeFilter
    :: CompositeFilter
compositeFilter =
  CompositeFilter' {_cfSubFilters = Nothing, _cfLogicOperator = Nothing}


-- | Sub filters.
cfSubFilters :: Lens' CompositeFilter [Filter]
cfSubFilters
  = lens _cfSubFilters (\ s a -> s{_cfSubFilters = a})
      . _Default
      . _Coerce

-- | The logic operator of the sub filter.
cfLogicOperator :: Lens' CompositeFilter (Maybe CompositeFilterLogicOperator)
cfLogicOperator
  = lens _cfLogicOperator
      (\ s a -> s{_cfLogicOperator = a})

instance FromJSON CompositeFilter where
        parseJSON
          = withObject "CompositeFilter"
              (\ o ->
                 CompositeFilter' <$>
                   (o .:? "subFilters" .!= mempty) <*>
                     (o .:? "logicOperator"))

instance ToJSON CompositeFilter where
        toJSON CompositeFilter'{..}
          = object
              (catMaybes
                 [("subFilters" .=) <$> _cfSubFilters,
                  ("logicOperator" .=) <$> _cfLogicOperator])

-- | The collection of fields that make up a displayed line
--
-- /See:/ 'resultDisplayLine' smart constructor.
newtype ResultDisplayLine =
  ResultDisplayLine'
    { _rdlFields :: Maybe [ResultDisplayField]
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ResultDisplayLine' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'rdlFields'
resultDisplayLine
    :: ResultDisplayLine
resultDisplayLine = ResultDisplayLine' {_rdlFields = Nothing}


rdlFields :: Lens' ResultDisplayLine [ResultDisplayField]
rdlFields
  = lens _rdlFields (\ s a -> s{_rdlFields = a}) .
      _Default
      . _Coerce

instance FromJSON ResultDisplayLine where
        parseJSON
          = withObject "ResultDisplayLine"
              (\ o ->
                 ResultDisplayLine' <$> (o .:? "fields" .!= mempty))

instance ToJSON ResultDisplayLine where
        toJSON ResultDisplayLine'{..}
          = object (catMaybes [("fields" .=) <$> _rdlFields])

-- | List of double values.
--
-- /See:/ 'doubleValues' smart constructor.
newtype DoubleValues =
  DoubleValues'
    { _dvValues :: Maybe [Textual Double]
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'DoubleValues' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'dvValues'
doubleValues
    :: DoubleValues
doubleValues = DoubleValues' {_dvValues = Nothing}


dvValues :: Lens' DoubleValues [Double]
dvValues
  = lens _dvValues (\ s a -> s{_dvValues = a}) .
      _Default
      . _Coerce

instance FromJSON DoubleValues where
        parseJSON
          = withObject "DoubleValues"
              (\ o ->
                 DoubleValues' <$> (o .:? "values" .!= mempty))

instance ToJSON DoubleValues where
        toJSON DoubleValues'{..}
          = object (catMaybes [("values" .=) <$> _dvValues])

-- | Snippet of the search result, which summarizes the content of the
-- resulting page.
--
-- /See:/ 'snippet' smart constructor.
data Snippet =
  Snippet'
    { _sMatchRanges :: !(Maybe [MatchRange])
    , _sSnippet     :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'Snippet' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'sMatchRanges'
--
-- * 'sSnippet'
snippet
    :: Snippet
snippet = Snippet' {_sMatchRanges = Nothing, _sSnippet = Nothing}


-- | The matched ranges in the snippet.
sMatchRanges :: Lens' Snippet [MatchRange]
sMatchRanges
  = lens _sMatchRanges (\ s a -> s{_sMatchRanges = a})
      . _Default
      . _Coerce

-- | The snippet of the document. The snippet of the document. May contain
-- escaped HTML character that should be unescaped prior to rendering.
sSnippet :: Lens' Snippet (Maybe Text)
sSnippet = lens _sSnippet (\ s a -> s{_sSnippet = a})

instance FromJSON Snippet where
        parseJSON
          = withObject "Snippet"
              (\ o ->
                 Snippet' <$>
                   (o .:? "matchRanges" .!= mempty) <*>
                     (o .:? "snippet"))

instance ToJSON Snippet where
        toJSON Snippet'{..}
          = object
              (catMaybes
                 [("matchRanges" .=) <$> _sMatchRanges,
                  ("snippet" .=) <$> _sSnippet])

-- | Used to provide a search operator for text properties. This is optional.
-- Search operators let users restrict the query to specific fields
-- relevant to the type of item being searched.
--
-- /See:/ 'textOperatorOptions' smart constructor.
data TextOperatorOptions =
  TextOperatorOptions'
    { _tooOperatorName           :: !(Maybe Text)
    , _tooExactMatchWithOperator :: !(Maybe Bool)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'TextOperatorOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'tooOperatorName'
--
-- * 'tooExactMatchWithOperator'
textOperatorOptions
    :: TextOperatorOptions
textOperatorOptions =
  TextOperatorOptions'
    {_tooOperatorName = Nothing, _tooExactMatchWithOperator = Nothing}


-- | Indicates the operator name required in the query in order to isolate
-- the text property. For example, if operatorName is *subject* and the
-- property\'s name is *subjectLine*, then queries like *subject:\<value>*
-- will show results only where the value of the property named
-- *subjectLine* matches *\<value>*. By contrast, a search that uses the
-- same *\<value>* without an operator will return all items where
-- *\<value>* matches the value of any text properties or text within the
-- content field for the item. The operator name can only contain lowercase
-- letters (a-z). The maximum length is 32 characters.
tooOperatorName :: Lens' TextOperatorOptions (Maybe Text)
tooOperatorName
  = lens _tooOperatorName
      (\ s a -> s{_tooOperatorName = a})

-- | If true, the text value will be tokenized as one atomic value in
-- operator searches and facet matches. For example, if the operator name
-- is \"genre\" and the value is \"science-fiction\" the query restrictions
-- \"genre:science\" and \"genre:fiction\" will not match the item;
-- \"genre:science-fiction\" will. Value matching is case-sensitive and
-- does not remove special characters. If false, the text will be
-- tokenized. For example, if the value is \"science-fiction\" the queries
-- \"genre:science\" and \"genre:fiction\" will match the item.
tooExactMatchWithOperator :: Lens' TextOperatorOptions (Maybe Bool)
tooExactMatchWithOperator
  = lens _tooExactMatchWithOperator
      (\ s a -> s{_tooExactMatchWithOperator = a})

instance FromJSON TextOperatorOptions where
        parseJSON
          = withObject "TextOperatorOptions"
              (\ o ->
                 TextOperatorOptions' <$>
                   (o .:? "operatorName") <*>
                     (o .:? "exactMatchWithOperator"))

instance ToJSON TextOperatorOptions where
        toJSON TextOperatorOptions'{..}
          = object
              (catMaybes
                 [("operatorName" .=) <$> _tooOperatorName,
                  ("exactMatchWithOperator" .=) <$>
                    _tooExactMatchWithOperator])

-- | Options to interpret user query.
--
-- /See:/ 'queryInterpretationOptions' smart constructor.
newtype QueryInterpretationOptions =
  QueryInterpretationOptions'
    { _qioDisableNlInterpretation :: Maybe Bool
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'QueryInterpretationOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'qioDisableNlInterpretation'
queryInterpretationOptions
    :: QueryInterpretationOptions
queryInterpretationOptions =
  QueryInterpretationOptions' {_qioDisableNlInterpretation = Nothing}


-- | Flag to disable natural language (NL) interpretation of queries. Default
-- is false, Set to true to disable natural language interpretation. NL
-- interpretation only applies to predefined datasources.
qioDisableNlInterpretation :: Lens' QueryInterpretationOptions (Maybe Bool)
qioDisableNlInterpretation
  = lens _qioDisableNlInterpretation
      (\ s a -> s{_qioDisableNlInterpretation = a})

instance FromJSON QueryInterpretationOptions where
        parseJSON
          = withObject "QueryInterpretationOptions"
              (\ o ->
                 QueryInterpretationOptions' <$>
                   (o .:? "disableNlInterpretation"))

instance ToJSON QueryInterpretationOptions where
        toJSON QueryInterpretationOptions'{..}
          = object
              (catMaybes
                 [("disableNlInterpretation" .=) <$>
                    _qioDisableNlInterpretation])

--
-- /See:/ 'resetSearchApplicationRequest' smart constructor.
newtype ResetSearchApplicationRequest =
  ResetSearchApplicationRequest'
    { _rsarDebugOptions :: Maybe DebugOptions
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ResetSearchApplicationRequest' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'rsarDebugOptions'
resetSearchApplicationRequest
    :: ResetSearchApplicationRequest
resetSearchApplicationRequest =
  ResetSearchApplicationRequest' {_rsarDebugOptions = Nothing}


-- | Common debug options.
rsarDebugOptions :: Lens' ResetSearchApplicationRequest (Maybe DebugOptions)
rsarDebugOptions
  = lens _rsarDebugOptions
      (\ s a -> s{_rsarDebugOptions = a})

instance FromJSON ResetSearchApplicationRequest where
        parseJSON
          = withObject "ResetSearchApplicationRequest"
              (\ o ->
                 ResetSearchApplicationRequest' <$>
                   (o .:? "debugOptions"))

instance ToJSON ResetSearchApplicationRequest where
        toJSON ResetSearchApplicationRequest'{..}
          = object
              (catMaybes
                 [("debugOptions" .=) <$> _rsarDebugOptions])

-- | Available metadata fields for the item.
--
-- /See:/ 'itemMetadata' smart constructor.
data ItemMetadata =
  ItemMetadata'
    { _imSourceRepositoryURL   :: !(Maybe Text)
    , _imHash                  :: !(Maybe Text)
    , _imObjectType            :: !(Maybe Text)
    , _imContainerName         :: !(Maybe Text)
    , _imInteractions          :: !(Maybe [Interaction])
    , _imMimeType              :: !(Maybe Text)
    , _imUpdateTime            :: !(Maybe DateTime')
    , _imKeywords              :: !(Maybe [Text])
    , _imTitle                 :: !(Maybe Text)
    , _imContentLanguage       :: !(Maybe Text)
    , _imSearchQualityMetadata :: !(Maybe SearchQualityMetadata)
    , _imCreateTime            :: !(Maybe DateTime')
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ItemMetadata' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'imSourceRepositoryURL'
--
-- * 'imHash'
--
-- * 'imObjectType'
--
-- * 'imContainerName'
--
-- * 'imInteractions'
--
-- * 'imMimeType'
--
-- * 'imUpdateTime'
--
-- * 'imKeywords'
--
-- * 'imTitle'
--
-- * 'imContentLanguage'
--
-- * 'imSearchQualityMetadata'
--
-- * 'imCreateTime'
itemMetadata
    :: ItemMetadata
itemMetadata =
  ItemMetadata'
    { _imSourceRepositoryURL = Nothing
    , _imHash = Nothing
    , _imObjectType = Nothing
    , _imContainerName = Nothing
    , _imInteractions = Nothing
    , _imMimeType = Nothing
    , _imUpdateTime = Nothing
    , _imKeywords = Nothing
    , _imTitle = Nothing
    , _imContentLanguage = Nothing
    , _imSearchQualityMetadata = Nothing
    , _imCreateTime = Nothing
    }


-- | Link to the source repository serving the data. Search results apply
-- this link to the title. The maximum length is 2048 characters.
imSourceRepositoryURL :: Lens' ItemMetadata (Maybe Text)
imSourceRepositoryURL
  = lens _imSourceRepositoryURL
      (\ s a -> s{_imSourceRepositoryURL = a})

-- | Hashing value provided by the API caller. This can be used with the
-- items.push method to calculate modified state. The maximum length is
-- 2048 characters.
imHash :: Lens' ItemMetadata (Maybe Text)
imHash = lens _imHash (\ s a -> s{_imHash = a})

-- | The type of the item. This should correspond to the name of an object
-- definition in the schema registered for the data source. For example, if
-- the schema for the data source contains an object definition with name
-- \'document\', then item indexing requests for objects of that type
-- should set objectType to \'document\'. The maximum length is 256
-- characters.
imObjectType :: Lens' ItemMetadata (Maybe Text)
imObjectType
  = lens _imObjectType (\ s a -> s{_imObjectType = a})

-- | The name of the container for this item. Deletion of the container item
-- leads to automatic deletion of this item. Note: ACLs are not inherited
-- from a container item. To provide ACL inheritance for an item, use the
-- inheritAclFrom field. The maximum length is 1536 characters.
imContainerName :: Lens' ItemMetadata (Maybe Text)
imContainerName
  = lens _imContainerName
      (\ s a -> s{_imContainerName = a})

-- | A list of interactions for the item. Interactions are used to improve
-- Search quality, but are not exposed to end users. The maximum number of
-- elements is 1000.
imInteractions :: Lens' ItemMetadata [Interaction]
imInteractions
  = lens _imInteractions
      (\ s a -> s{_imInteractions = a})
      . _Default
      . _Coerce

-- | The original mime-type of ItemContent.content in the source repository.
-- The maximum length is 256 characters.
imMimeType :: Lens' ItemMetadata (Maybe Text)
imMimeType
  = lens _imMimeType (\ s a -> s{_imMimeType = a})

-- | The time when the item was last modified in the source repository.
imUpdateTime :: Lens' ItemMetadata (Maybe UTCTime)
imUpdateTime
  = lens _imUpdateTime (\ s a -> s{_imUpdateTime = a})
      . mapping _DateTime

-- | Additional keywords or phrases that should match the item. Used
-- internally for user generated content. The maximum number of elements is
-- 100. The maximum length is 8192 characters.
imKeywords :: Lens' ItemMetadata [Text]
imKeywords
  = lens _imKeywords (\ s a -> s{_imKeywords = a}) .
      _Default
      . _Coerce

-- | The title of the item. If given, this will be the displayed title of the
-- Search result. The maximum length is 2048 characters.
imTitle :: Lens' ItemMetadata (Maybe Text)
imTitle = lens _imTitle (\ s a -> s{_imTitle = a})

-- | The BCP-47 language code for the item, such as \"en-US\" or \"sr-Latn\".
-- For more information, see
-- http:\/\/www.unicode.org\/reports\/tr35\/#Unicode_locale_identifier. The
-- maximum length is 32 characters.
imContentLanguage :: Lens' ItemMetadata (Maybe Text)
imContentLanguage
  = lens _imContentLanguage
      (\ s a -> s{_imContentLanguage = a})

-- | Additional search quality metadata of the item
imSearchQualityMetadata :: Lens' ItemMetadata (Maybe SearchQualityMetadata)
imSearchQualityMetadata
  = lens _imSearchQualityMetadata
      (\ s a -> s{_imSearchQualityMetadata = a})

-- | The time when the item was created in the source repository.
imCreateTime :: Lens' ItemMetadata (Maybe UTCTime)
imCreateTime
  = lens _imCreateTime (\ s a -> s{_imCreateTime = a})
      . mapping _DateTime

instance FromJSON ItemMetadata where
        parseJSON
          = withObject "ItemMetadata"
              (\ o ->
                 ItemMetadata' <$>
                   (o .:? "sourceRepositoryUrl") <*> (o .:? "hash") <*>
                     (o .:? "objectType")
                     <*> (o .:? "containerName")
                     <*> (o .:? "interactions" .!= mempty)
                     <*> (o .:? "mimeType")
                     <*> (o .:? "updateTime")
                     <*> (o .:? "keywords" .!= mempty)
                     <*> (o .:? "title")
                     <*> (o .:? "contentLanguage")
                     <*> (o .:? "searchQualityMetadata")
                     <*> (o .:? "createTime"))

instance ToJSON ItemMetadata where
        toJSON ItemMetadata'{..}
          = object
              (catMaybes
                 [("sourceRepositoryUrl" .=) <$>
                    _imSourceRepositoryURL,
                  ("hash" .=) <$> _imHash,
                  ("objectType" .=) <$> _imObjectType,
                  ("containerName" .=) <$> _imContainerName,
                  ("interactions" .=) <$> _imInteractions,
                  ("mimeType" .=) <$> _imMimeType,
                  ("updateTime" .=) <$> _imUpdateTime,
                  ("keywords" .=) <$> _imKeywords,
                  ("title" .=) <$> _imTitle,
                  ("contentLanguage" .=) <$> _imContentLanguage,
                  ("searchQualityMetadata" .=) <$>
                    _imSearchQualityMetadata,
                  ("createTime" .=) <$> _imCreateTime])

-- | Filter options to be applied on query.
--
-- /See:/ 'filterOptions' smart constructor.
data FilterOptions =
  FilterOptions'
    { _foObjectType :: !(Maybe Text)
    , _foFilter     :: !(Maybe Filter)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'FilterOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'foObjectType'
--
-- * 'foFilter'
filterOptions
    :: FilterOptions
filterOptions = FilterOptions' {_foObjectType = Nothing, _foFilter = Nothing}


-- | If object_type is set, only objects of that type are returned. This
-- should correspond to the name of the object that was registered within
-- the definition of schema. The maximum length is 256 characters.
foObjectType :: Lens' FilterOptions (Maybe Text)
foObjectType
  = lens _foObjectType (\ s a -> s{_foObjectType = a})

-- | Generic filter to restrict the search, such as \`lang:en\`,
-- \`site:xyz\`.
foFilter :: Lens' FilterOptions (Maybe Filter)
foFilter = lens _foFilter (\ s a -> s{_foFilter = a})

instance FromJSON FilterOptions where
        parseJSON
          = withObject "FilterOptions"
              (\ o ->
                 FilterOptions' <$>
                   (o .:? "objectType") <*> (o .:? "filter"))

instance ToJSON FilterOptions where
        toJSON FilterOptions'{..}
          = object
              (catMaybes
                 [("objectType" .=) <$> _foObjectType,
                  ("filter" .=) <$> _foFilter])

-- | Structured results that are returned as part of search request.
--
-- /See:/ 'structuredResult' smart constructor.
newtype StructuredResult =
  StructuredResult'
    { _srPerson :: Maybe Person
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'StructuredResult' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'srPerson'
structuredResult
    :: StructuredResult
structuredResult = StructuredResult' {_srPerson = Nothing}


-- | Representation of a person
srPerson :: Lens' StructuredResult (Maybe Person)
srPerson = lens _srPerson (\ s a -> s{_srPerson = a})

instance FromJSON StructuredResult where
        parseJSON
          = withObject "StructuredResult"
              (\ o -> StructuredResult' <$> (o .:? "person"))

instance ToJSON StructuredResult where
        toJSON StructuredResult'{..}
          = object (catMaybes [("person" .=) <$> _srPerson])

--
-- /See:/ 'processingError' smart constructor.
data ProcessingError =
  ProcessingError'
    { _peFieldViolations :: !(Maybe [FieldViolation])
    , _peCode            :: !(Maybe ProcessingErrorCode)
    , _peErrorMessage    :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ProcessingError' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'peFieldViolations'
--
-- * 'peCode'
--
-- * 'peErrorMessage'
processingError
    :: ProcessingError
processingError =
  ProcessingError'
    {_peFieldViolations = Nothing, _peCode = Nothing, _peErrorMessage = Nothing}


-- | In case the item fields are invalid, this field contains the details
-- about the validation errors.
peFieldViolations :: Lens' ProcessingError [FieldViolation]
peFieldViolations
  = lens _peFieldViolations
      (\ s a -> s{_peFieldViolations = a})
      . _Default
      . _Coerce

-- | Error code indicating the nature of the error.
peCode :: Lens' ProcessingError (Maybe ProcessingErrorCode)
peCode = lens _peCode (\ s a -> s{_peCode = a})

-- | Description of the error.
peErrorMessage :: Lens' ProcessingError (Maybe Text)
peErrorMessage
  = lens _peErrorMessage
      (\ s a -> s{_peErrorMessage = a})

instance FromJSON ProcessingError where
        parseJSON
          = withObject "ProcessingError"
              (\ o ->
                 ProcessingError' <$>
                   (o .:? "fieldViolations" .!= mempty) <*>
                     (o .:? "code")
                     <*> (o .:? "errorMessage"))

instance ToJSON ProcessingError where
        toJSON ProcessingError'{..}
          = object
              (catMaybes
                 [("fieldViolations" .=) <$> _peFieldViolations,
                  ("code" .=) <$> _peCode,
                  ("errorMessage" .=) <$> _peErrorMessage])

--
-- /See:/ 'listItemNamesForUnmAppedIdentityResponse' smart constructor.
data ListItemNamesForUnmAppedIdentityResponse =
  ListItemNamesForUnmAppedIdentityResponse'
    { _linfuairNextPageToken :: !(Maybe Text)
    , _linfuairItemNames     :: !(Maybe [Text])
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ListItemNamesForUnmAppedIdentityResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'linfuairNextPageToken'
--
-- * 'linfuairItemNames'
listItemNamesForUnmAppedIdentityResponse
    :: ListItemNamesForUnmAppedIdentityResponse
listItemNamesForUnmAppedIdentityResponse =
  ListItemNamesForUnmAppedIdentityResponse'
    {_linfuairNextPageToken = Nothing, _linfuairItemNames = Nothing}


-- | Token to retrieve the next page of results, or empty if there are no
-- more results in the list.
linfuairNextPageToken :: Lens' ListItemNamesForUnmAppedIdentityResponse (Maybe Text)
linfuairNextPageToken
  = lens _linfuairNextPageToken
      (\ s a -> s{_linfuairNextPageToken = a})

linfuairItemNames :: Lens' ListItemNamesForUnmAppedIdentityResponse [Text]
linfuairItemNames
  = lens _linfuairItemNames
      (\ s a -> s{_linfuairItemNames = a})
      . _Default
      . _Coerce

instance FromJSON
           ListItemNamesForUnmAppedIdentityResponse
         where
        parseJSON
          = withObject
              "ListItemNamesForUnmAppedIdentityResponse"
              (\ o ->
                 ListItemNamesForUnmAppedIdentityResponse' <$>
                   (o .:? "nextPageToken") <*>
                     (o .:? "itemNames" .!= mempty))

instance ToJSON
           ListItemNamesForUnmAppedIdentityResponse
         where
        toJSON ListItemNamesForUnmAppedIdentityResponse'{..}
          = object
              (catMaybes
                 [("nextPageToken" .=) <$> _linfuairNextPageToken,
                  ("itemNames" .=) <$> _linfuairItemNames])

-- | Access control list information for the item. For more information see
-- https:\/\/developers.google.com\/cloud-search\/docs\/guides\/index-your-data#acls
--
-- /See:/ 'itemACL' smart constructor.
data ItemACL =
  ItemACL'
    { _iaOwners             :: !(Maybe [Principal])
    , _iaReaders            :: !(Maybe [Principal])
    , _iaACLInheritanceType :: !(Maybe ItemACLACLInheritanceType)
    , _iaInheritACLFrom     :: !(Maybe Text)
    , _iaDeniedReaders      :: !(Maybe [Principal])
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ItemACL' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'iaOwners'
--
-- * 'iaReaders'
--
-- * 'iaACLInheritanceType'
--
-- * 'iaInheritACLFrom'
--
-- * 'iaDeniedReaders'
itemACL
    :: ItemACL
itemACL =
  ItemACL'
    { _iaOwners = Nothing
    , _iaReaders = Nothing
    , _iaACLInheritanceType = Nothing
    , _iaInheritACLFrom = Nothing
    , _iaDeniedReaders = Nothing
    }


-- | Optional. List of owners for the item. This field has no bearing on
-- document access permissions. It does, however, offer a slight ranking
-- boosts items where the querying user is an owner. The maximum number of
-- elements is 5.
iaOwners :: Lens' ItemACL [Principal]
iaOwners
  = lens _iaOwners (\ s a -> s{_iaOwners = a}) .
      _Default
      . _Coerce

-- | List of principals who are allowed to see the item in search results.
-- Optional if inheriting permissions from another item or if the item is
-- not intended to be visible, such as virtual containers. The maximum
-- number of elements is 1000.
iaReaders :: Lens' ItemACL [Principal]
iaReaders
  = lens _iaReaders (\ s a -> s{_iaReaders = a}) .
      _Default
      . _Coerce

-- | Sets the type of access rules to apply when an item inherits its ACL
-- from a parent. This should always be set in tandem with the
-- inheritAclFrom field. Also, when the inheritAclFrom field is set, this
-- field should be set to a valid AclInheritanceType.
iaACLInheritanceType :: Lens' ItemACL (Maybe ItemACLACLInheritanceType)
iaACLInheritanceType
  = lens _iaACLInheritanceType
      (\ s a -> s{_iaACLInheritanceType = a})

-- | Name of the item to inherit the Access Permission List (ACL) from. Note:
-- ACL inheritance *only* provides access permissions to child items and
-- does not define structural relationships, nor does it provide convenient
-- ways to delete large groups of items. Deleting an ACL parent from the
-- index only alters the access permissions of child items that reference
-- the parent in the inheritAclFrom field. The item is still in the index,
-- but may not visible in search results. By contrast, deletion of a
-- container item also deletes all items that reference the container via
-- the containerName field. The maximum length for this field is 1536
-- characters.
iaInheritACLFrom :: Lens' ItemACL (Maybe Text)
iaInheritACLFrom
  = lens _iaInheritACLFrom
      (\ s a -> s{_iaInheritACLFrom = a})

-- | List of principals who are explicitly denied access to the item in
-- search results. While principals are denied access by default, use
-- denied readers to handle exceptions and override the list allowed
-- readers. The maximum number of elements is 100.
iaDeniedReaders :: Lens' ItemACL [Principal]
iaDeniedReaders
  = lens _iaDeniedReaders
      (\ s a -> s{_iaDeniedReaders = a})
      . _Default
      . _Coerce

instance FromJSON ItemACL where
        parseJSON
          = withObject "ItemACL"
              (\ o ->
                 ItemACL' <$>
                   (o .:? "owners" .!= mempty) <*>
                     (o .:? "readers" .!= mempty)
                     <*> (o .:? "aclInheritanceType")
                     <*> (o .:? "inheritAclFrom")
                     <*> (o .:? "deniedReaders" .!= mempty))

instance ToJSON ItemACL where
        toJSON ItemACL'{..}
          = object
              (catMaybes
                 [("owners" .=) <$> _iaOwners,
                  ("readers" .=) <$> _iaReaders,
                  ("aclInheritanceType" .=) <$> _iaACLInheritanceType,
                  ("inheritAclFrom" .=) <$> _iaInheritACLFrom,
                  ("deniedReaders" .=) <$> _iaDeniedReaders])

-- | Definition of a single value with generic type.
--
-- /See:/ 'value' smart constructor.
data Value =
  Value'
    { _vIntegerValue   :: !(Maybe (Textual Int64))
    , _vTimestampValue :: !(Maybe DateTime')
    , _vDoubleValue    :: !(Maybe (Textual Double))
    , _vStringValue    :: !(Maybe Text)
    , _vDateValue      :: !(Maybe Date)
    , _vBooleanValue   :: !(Maybe Bool)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'Value' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'vIntegerValue'
--
-- * 'vTimestampValue'
--
-- * 'vDoubleValue'
--
-- * 'vStringValue'
--
-- * 'vDateValue'
--
-- * 'vBooleanValue'
value
    :: Value
value =
  Value'
    { _vIntegerValue = Nothing
    , _vTimestampValue = Nothing
    , _vDoubleValue = Nothing
    , _vStringValue = Nothing
    , _vDateValue = Nothing
    , _vBooleanValue = Nothing
    }


vIntegerValue :: Lens' Value (Maybe Int64)
vIntegerValue
  = lens _vIntegerValue
      (\ s a -> s{_vIntegerValue = a})
      . mapping _Coerce

vTimestampValue :: Lens' Value (Maybe UTCTime)
vTimestampValue
  = lens _vTimestampValue
      (\ s a -> s{_vTimestampValue = a})
      . mapping _DateTime

vDoubleValue :: Lens' Value (Maybe Double)
vDoubleValue
  = lens _vDoubleValue (\ s a -> s{_vDoubleValue = a})
      . mapping _Coerce

vStringValue :: Lens' Value (Maybe Text)
vStringValue
  = lens _vStringValue (\ s a -> s{_vStringValue = a})

vDateValue :: Lens' Value (Maybe Date)
vDateValue
  = lens _vDateValue (\ s a -> s{_vDateValue = a})

vBooleanValue :: Lens' Value (Maybe Bool)
vBooleanValue
  = lens _vBooleanValue
      (\ s a -> s{_vBooleanValue = a})

instance FromJSON Value where
        parseJSON
          = withObject "Value"
              (\ o ->
                 Value' <$>
                   (o .:? "integerValue") <*> (o .:? "timestampValue")
                     <*> (o .:? "doubleValue")
                     <*> (o .:? "stringValue")
                     <*> (o .:? "dateValue")
                     <*> (o .:? "booleanValue"))

instance ToJSON Value where
        toJSON Value'{..}
          = object
              (catMaybes
                 [("integerValue" .=) <$> _vIntegerValue,
                  ("timestampValue" .=) <$> _vTimestampValue,
                  ("doubleValue" .=) <$> _vDoubleValue,
                  ("stringValue" .=) <$> _vStringValue,
                  ("dateValue" .=) <$> _vDateValue,
                  ("booleanValue" .=) <$> _vBooleanValue])

--
-- /See:/ 'fieldViolation' smart constructor.
data FieldViolation =
  FieldViolation'
    { _fvField       :: !(Maybe Text)
    , _fvDescription :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'FieldViolation' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'fvField'
--
-- * 'fvDescription'
fieldViolation
    :: FieldViolation
fieldViolation = FieldViolation' {_fvField = Nothing, _fvDescription = Nothing}


-- | Path of field with violation.
fvField :: Lens' FieldViolation (Maybe Text)
fvField = lens _fvField (\ s a -> s{_fvField = a})

-- | Description of the error.
fvDescription :: Lens' FieldViolation (Maybe Text)
fvDescription
  = lens _fvDescription
      (\ s a -> s{_fvDescription = a})

instance FromJSON FieldViolation where
        parseJSON
          = withObject "FieldViolation"
              (\ o ->
                 FieldViolation' <$>
                   (o .:? "field") <*> (o .:? "description"))

instance ToJSON FieldViolation where
        toJSON FieldViolation'{..}
          = object
              (catMaybes
                 [("field" .=) <$> _fvField,
                  ("description" .=) <$> _fvDescription])

-- | A metaline is a list of properties that are displayed along with the
-- search result to provide context.
--
-- /See:/ 'metaline' smart constructor.
newtype Metaline =
  Metaline'
    { _mProperties :: Maybe [DisplayedProperty]
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'Metaline' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'mProperties'
metaline
    :: Metaline
metaline = Metaline' {_mProperties = Nothing}


-- | The list of displayed properties for the metaline. The maxiumum number
-- of properties is 5.
mProperties :: Lens' Metaline [DisplayedProperty]
mProperties
  = lens _mProperties (\ s a -> s{_mProperties = a}) .
      _Default
      . _Coerce

instance FromJSON Metaline where
        parseJSON
          = withObject "Metaline"
              (\ o ->
                 Metaline' <$> (o .:? "properties" .!= mempty))

instance ToJSON Metaline where
        toJSON Metaline'{..}
          = object
              (catMaybes [("properties" .=) <$> _mProperties])

-- | A bucket in a facet is the basic unit of operation. A bucket can
-- comprise either a single value OR a contiguous range of values,
-- depending on the type of the field bucketed. FacetBucket is currently
-- used only for returning the response object.
--
-- /See:/ 'facetBucket' smart constructor.
data FacetBucket =
  FacetBucket'
    { _fbValue      :: !(Maybe Value)
    , _fbCount      :: !(Maybe (Textual Int32))
    , _fbPercentage :: !(Maybe (Textual Int32))
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'FacetBucket' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'fbValue'
--
-- * 'fbCount'
--
-- * 'fbPercentage'
facetBucket
    :: FacetBucket
facetBucket =
  FacetBucket' {_fbValue = Nothing, _fbCount = Nothing, _fbPercentage = Nothing}


fbValue :: Lens' FacetBucket (Maybe Value)
fbValue = lens _fbValue (\ s a -> s{_fbValue = a})

-- | Number of results that match the bucket value. Counts are only returned
-- for searches when count accuracy is ensured. Can be empty.
fbCount :: Lens' FacetBucket (Maybe Int32)
fbCount
  = lens _fbCount (\ s a -> s{_fbCount = a}) .
      mapping _Coerce

-- | Percent of results that match the bucket value. This value is between
-- (0-100]. Percentages are returned for all searches, but are an estimate.
-- Because percentages are always returned, you should render percentages
-- instead of counts.
fbPercentage :: Lens' FacetBucket (Maybe Int32)
fbPercentage
  = lens _fbPercentage (\ s a -> s{_fbPercentage = a})
      . mapping _Coerce

instance FromJSON FacetBucket where
        parseJSON
          = withObject "FacetBucket"
              (\ o ->
                 FacetBucket' <$>
                   (o .:? "value") <*> (o .:? "count") <*>
                     (o .:? "percentage"))

instance ToJSON FacetBucket where
        toJSON FacetBucket'{..}
          = object
              (catMaybes
                 [("value" .=) <$> _fbValue,
                  ("count" .=) <$> _fbCount,
                  ("percentage" .=) <$> _fbPercentage])

--
-- /See:/ 'statusDetailsItem' smart constructor.
newtype StatusDetailsItem =
  StatusDetailsItem'
    { _sdiAddtional :: HashMap Text JSONValue
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'StatusDetailsItem' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'sdiAddtional'
statusDetailsItem
    :: HashMap Text JSONValue -- ^ 'sdiAddtional'
    -> StatusDetailsItem
statusDetailsItem pSdiAddtional_ =
  StatusDetailsItem' {_sdiAddtional = _Coerce # pSdiAddtional_}


-- | Properties of the object. Contains field \'type with type URL.
sdiAddtional :: Lens' StatusDetailsItem (HashMap Text JSONValue)
sdiAddtional
  = lens _sdiAddtional (\ s a -> s{_sdiAddtional = a})
      . _Coerce

instance FromJSON StatusDetailsItem where
        parseJSON
          = withObject "StatusDetailsItem"
              (\ o -> StatusDetailsItem' <$> (parseJSONObject o))

instance ToJSON StatusDetailsItem where
        toJSON = toJSON . _sdiAddtional

-- | Used to provide a search operator for timestamp properties. This is
-- optional. Search operators let users restrict the query to specific
-- fields relevant to the type of item being searched.
--
-- /See:/ 'timestampOperatorOptions' smart constructor.
data TimestampOperatorOptions =
  TimestampOperatorOptions'
    { _tOperatorName            :: !(Maybe Text)
    , _tLessThanOperatorName    :: !(Maybe Text)
    , _tGreaterThanOperatorName :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'TimestampOperatorOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'tOperatorName'
--
-- * 'tLessThanOperatorName'
--
-- * 'tGreaterThanOperatorName'
timestampOperatorOptions
    :: TimestampOperatorOptions
timestampOperatorOptions =
  TimestampOperatorOptions'
    { _tOperatorName = Nothing
    , _tLessThanOperatorName = Nothing
    , _tGreaterThanOperatorName = Nothing
    }


-- | Indicates the operator name required in the query in order to isolate
-- the timestamp property. For example, if operatorName is *closedon* and
-- the property\'s name is *closeDate*, then queries like
-- *closedon:\<value>* will show results only where the value of the
-- property named *closeDate* matches *\<value>*. By contrast, a search
-- that uses the same *\<value>* without an operator will return all items
-- where *\<value>* matches the value of any String properties or text
-- within the content field for the item. The operator name can only
-- contain lowercase letters (a-z). The maximum length is 32 characters.
tOperatorName :: Lens' TimestampOperatorOptions (Maybe Text)
tOperatorName
  = lens _tOperatorName
      (\ s a -> s{_tOperatorName = a})

-- | Indicates the operator name required in the query in order to isolate
-- the timestamp property using the less-than operator. For example, if
-- lessThanOperatorName is *closedbefore* and the property\'s name is
-- *closeDate*, then queries like *closedbefore:\<value>* will show results
-- only where the value of the property named *closeDate* is earlier than
-- *\<value>*. The operator name can only contain lowercase letters (a-z).
-- The maximum length is 32 characters.
tLessThanOperatorName :: Lens' TimestampOperatorOptions (Maybe Text)
tLessThanOperatorName
  = lens _tLessThanOperatorName
      (\ s a -> s{_tLessThanOperatorName = a})

-- | Indicates the operator name required in the query in order to isolate
-- the timestamp property using the greater-than operator. For example, if
-- greaterThanOperatorName is *closedafter* and the property\'s name is
-- *closeDate*, then queries like *closedafter:\<value>* will show results
-- only where the value of the property named *closeDate* is later than
-- *\<value>*. The operator name can only contain lowercase letters (a-z).
-- The maximum length is 32 characters.
tGreaterThanOperatorName :: Lens' TimestampOperatorOptions (Maybe Text)
tGreaterThanOperatorName
  = lens _tGreaterThanOperatorName
      (\ s a -> s{_tGreaterThanOperatorName = a})

instance FromJSON TimestampOperatorOptions where
        parseJSON
          = withObject "TimestampOperatorOptions"
              (\ o ->
                 TimestampOperatorOptions' <$>
                   (o .:? "operatorName") <*>
                     (o .:? "lessThanOperatorName")
                     <*> (o .:? "greaterThanOperatorName"))

instance ToJSON TimestampOperatorOptions where
        toJSON TimestampOperatorOptions'{..}
          = object
              (catMaybes
                 [("operatorName" .=) <$> _tOperatorName,
                  ("lessThanOperatorName" .=) <$>
                    _tLessThanOperatorName,
                  ("greaterThanOperatorName" .=) <$>
                    _tGreaterThanOperatorName])

-- | Used to provide a search operator for integer properties. This is
-- optional. Search operators let users restrict the query to specific
-- fields relevant to the type of item being searched.
--
-- /See:/ 'integerOperatorOptions' smart constructor.
data IntegerOperatorOptions =
  IntegerOperatorOptions'
    { _iooOperatorName            :: !(Maybe Text)
    , _iooLessThanOperatorName    :: !(Maybe Text)
    , _iooGreaterThanOperatorName :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'IntegerOperatorOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'iooOperatorName'
--
-- * 'iooLessThanOperatorName'
--
-- * 'iooGreaterThanOperatorName'
integerOperatorOptions
    :: IntegerOperatorOptions
integerOperatorOptions =
  IntegerOperatorOptions'
    { _iooOperatorName = Nothing
    , _iooLessThanOperatorName = Nothing
    , _iooGreaterThanOperatorName = Nothing
    }


-- | Indicates the operator name required in the query in order to isolate
-- the integer property. For example, if operatorName is *priority* and the
-- property\'s name is *priorityVal*, then queries like *priority:\<value>*
-- will show results only where the value of the property named
-- *priorityVal* matches *\<value>*. By contrast, a search that uses the
-- same *\<value>* without an operator will return all items where
-- *\<value>* matches the value of any String properties or text within the
-- content field for the item. The operator name can only contain lowercase
-- letters (a-z). The maximum length is 32 characters.
iooOperatorName :: Lens' IntegerOperatorOptions (Maybe Text)
iooOperatorName
  = lens _iooOperatorName
      (\ s a -> s{_iooOperatorName = a})

-- | Indicates the operator name required in the query in order to isolate
-- the integer property using the less-than operator. For example, if
-- lessThanOperatorName is *prioritybelow* and the property\'s name is
-- *priorityVal*, then queries like *prioritybelow:\<value>* will show
-- results only where the value of the property named *priorityVal* is less
-- than *\<value>*. The operator name can only contain lowercase letters
-- (a-z). The maximum length is 32 characters.
iooLessThanOperatorName :: Lens' IntegerOperatorOptions (Maybe Text)
iooLessThanOperatorName
  = lens _iooLessThanOperatorName
      (\ s a -> s{_iooLessThanOperatorName = a})

-- | Indicates the operator name required in the query in order to isolate
-- the integer property using the greater-than operator. For example, if
-- greaterThanOperatorName is *priorityabove* and the property\'s name is
-- *priorityVal*, then queries like *priorityabove:\<value>* will show
-- results only where the value of the property named *priorityVal* is
-- greater than *\<value>*. The operator name can only contain lowercase
-- letters (a-z). The maximum length is 32 characters.
iooGreaterThanOperatorName :: Lens' IntegerOperatorOptions (Maybe Text)
iooGreaterThanOperatorName
  = lens _iooGreaterThanOperatorName
      (\ s a -> s{_iooGreaterThanOperatorName = a})

instance FromJSON IntegerOperatorOptions where
        parseJSON
          = withObject "IntegerOperatorOptions"
              (\ o ->
                 IntegerOperatorOptions' <$>
                   (o .:? "operatorName") <*>
                     (o .:? "lessThanOperatorName")
                     <*> (o .:? "greaterThanOperatorName"))

instance ToJSON IntegerOperatorOptions where
        toJSON IntegerOperatorOptions'{..}
          = object
              (catMaybes
                 [("operatorName" .=) <$> _iooOperatorName,
                  ("lessThanOperatorName" .=) <$>
                    _iooLessThanOperatorName,
                  ("greaterThanOperatorName" .=) <$>
                    _iooGreaterThanOperatorName])

-- | This field does not contain anything as of now and is just used as an
-- indicator that the suggest result was a phrase completion.
--
-- /See:/ 'querySuggestion' smart constructor.
data QuerySuggestion =
  QuerySuggestion'
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'QuerySuggestion' with the minimum fields required to make a request.
--
querySuggestion
    :: QuerySuggestion
querySuggestion = QuerySuggestion'


instance FromJSON QuerySuggestion where
        parseJSON
          = withObject "QuerySuggestion"
              (\ o -> pure QuerySuggestion')

instance ToJSON QuerySuggestion where
        toJSON = const emptyObject

--
-- /See:/ 'listSearchApplicationsResponse' smart constructor.
data ListSearchApplicationsResponse =
  ListSearchApplicationsResponse'
    { _lsarNextPageToken      :: !(Maybe Text)
    , _lsarSearchApplications :: !(Maybe [SearchApplication])
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ListSearchApplicationsResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'lsarNextPageToken'
--
-- * 'lsarSearchApplications'
listSearchApplicationsResponse
    :: ListSearchApplicationsResponse
listSearchApplicationsResponse =
  ListSearchApplicationsResponse'
    {_lsarNextPageToken = Nothing, _lsarSearchApplications = Nothing}


-- | Token to retrieve the next page of results, or empty if there are no
-- more results in the list.
lsarNextPageToken :: Lens' ListSearchApplicationsResponse (Maybe Text)
lsarNextPageToken
  = lens _lsarNextPageToken
      (\ s a -> s{_lsarNextPageToken = a})

lsarSearchApplications :: Lens' ListSearchApplicationsResponse [SearchApplication]
lsarSearchApplications
  = lens _lsarSearchApplications
      (\ s a -> s{_lsarSearchApplications = a})
      . _Default
      . _Coerce

instance FromJSON ListSearchApplicationsResponse
         where
        parseJSON
          = withObject "ListSearchApplicationsResponse"
              (\ o ->
                 ListSearchApplicationsResponse' <$>
                   (o .:? "nextPageToken") <*>
                     (o .:? "searchApplications" .!= mempty))

instance ToJSON ListSearchApplicationsResponse where
        toJSON ListSearchApplicationsResponse'{..}
          = object
              (catMaybes
                 [("nextPageToken" .=) <$> _lsarNextPageToken,
                  ("searchApplications" .=) <$>
                    _lsarSearchApplications])

-- | Debugging information about the result.
--
-- /See:/ 'resultDebugInfo' smart constructor.
newtype ResultDebugInfo =
  ResultDebugInfo'
    { _rdiFormattedDebugInfo :: Maybe Text
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ResultDebugInfo' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'rdiFormattedDebugInfo'
resultDebugInfo
    :: ResultDebugInfo
resultDebugInfo = ResultDebugInfo' {_rdiFormattedDebugInfo = Nothing}


-- | General debug info formatted for display.
rdiFormattedDebugInfo :: Lens' ResultDebugInfo (Maybe Text)
rdiFormattedDebugInfo
  = lens _rdiFormattedDebugInfo
      (\ s a -> s{_rdiFormattedDebugInfo = a})

instance FromJSON ResultDebugInfo where
        parseJSON
          = withObject "ResultDebugInfo"
              (\ o ->
                 ResultDebugInfo' <$> (o .:? "formattedDebugInfo"))

instance ToJSON ResultDebugInfo where
        toJSON ResultDebugInfo'{..}
          = object
              (catMaybes
                 [("formattedDebugInfo" .=) <$>
                    _rdiFormattedDebugInfo])

--
-- /See:/ 'itemCountByStatus' smart constructor.
data ItemCountByStatus =
  ItemCountByStatus'
    { _icbsCount      :: !(Maybe (Textual Int64))
    , _icbsStatusCode :: !(Maybe ItemCountByStatusStatusCode)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ItemCountByStatus' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'icbsCount'
--
-- * 'icbsStatusCode'
itemCountByStatus
    :: ItemCountByStatus
itemCountByStatus =
  ItemCountByStatus' {_icbsCount = Nothing, _icbsStatusCode = Nothing}


-- | Number of items matching the status code.
icbsCount :: Lens' ItemCountByStatus (Maybe Int64)
icbsCount
  = lens _icbsCount (\ s a -> s{_icbsCount = a}) .
      mapping _Coerce

-- | Status of the items.
icbsStatusCode :: Lens' ItemCountByStatus (Maybe ItemCountByStatusStatusCode)
icbsStatusCode
  = lens _icbsStatusCode
      (\ s a -> s{_icbsStatusCode = a})

instance FromJSON ItemCountByStatus where
        parseJSON
          = withObject "ItemCountByStatus"
              (\ o ->
                 ItemCountByStatus' <$>
                   (o .:? "count") <*> (o .:? "statusCode"))

instance ToJSON ItemCountByStatus where
        toJSON ItemCountByStatus'{..}
          = object
              (catMaybes
                 [("count" .=) <$> _icbsCount,
                  ("statusCode" .=) <$> _icbsStatusCode])

-- | Options for timestamp properties.
--
-- /See:/ 'timestampPropertyOptions' smart constructor.
newtype TimestampPropertyOptions =
  TimestampPropertyOptions'
    { _tpoOperatorOptions :: Maybe TimestampOperatorOptions
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'TimestampPropertyOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'tpoOperatorOptions'
timestampPropertyOptions
    :: TimestampPropertyOptions
timestampPropertyOptions =
  TimestampPropertyOptions' {_tpoOperatorOptions = Nothing}


-- | If set, describes how the timestamp should be used as a search operator.
tpoOperatorOptions :: Lens' TimestampPropertyOptions (Maybe TimestampOperatorOptions)
tpoOperatorOptions
  = lens _tpoOperatorOptions
      (\ s a -> s{_tpoOperatorOptions = a})

instance FromJSON TimestampPropertyOptions where
        parseJSON
          = withObject "TimestampPropertyOptions"
              (\ o ->
                 TimestampPropertyOptions' <$>
                   (o .:? "operatorOptions"))

instance ToJSON TimestampPropertyOptions where
        toJSON TimestampPropertyOptions'{..}
          = object
              (catMaybes
                 [("operatorOptions" .=) <$> _tpoOperatorOptions])

-- | Result count information
--
-- /See:/ 'resultCounts' smart constructor.
newtype ResultCounts =
  ResultCounts'
    { _rcSourceResultCounts :: Maybe [SourceResultCount]
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'ResultCounts' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'rcSourceResultCounts'
resultCounts
    :: ResultCounts
resultCounts = ResultCounts' {_rcSourceResultCounts = Nothing}


-- | Result count information for each source with results.
rcSourceResultCounts :: Lens' ResultCounts [SourceResultCount]
rcSourceResultCounts
  = lens _rcSourceResultCounts
      (\ s a -> s{_rcSourceResultCounts = a})
      . _Default
      . _Coerce

instance FromJSON ResultCounts where
        parseJSON
          = withObject "ResultCounts"
              (\ o ->
                 ResultCounts' <$>
                   (o .:? "sourceResultCounts" .!= mempty))

instance ToJSON ResultCounts where
        toJSON ResultCounts'{..}
          = object
              (catMaybes
                 [("sourceResultCounts" .=) <$>
                    _rcSourceResultCounts])

-- | Indicates which freshness property to use when adjusting search ranking
-- for an item. Fresher, more recent dates indicate higher quality. Use the
-- freshness option property that best works with your data. For fileshare
-- documents, last modified time is most relevant. For calendar event data,
-- the time when the event occurs is a more relevant freshness indicator.
-- In this way, calendar events that occur closer to the time of the search
-- query are considered higher quality and ranked accordingly.
--
-- /See:/ 'freshnessOptions' smart constructor.
data FreshnessOptions =
  FreshnessOptions'
    { _foFreshnessDuration :: !(Maybe GDuration)
    , _foFreshnessProperty :: !(Maybe Text)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'FreshnessOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'foFreshnessDuration'
--
-- * 'foFreshnessProperty'
freshnessOptions
    :: FreshnessOptions
freshnessOptions =
  FreshnessOptions'
    {_foFreshnessDuration = Nothing, _foFreshnessProperty = Nothing}


-- | The duration after which an object should be considered stale. The
-- default value is 180 days (in seconds).
foFreshnessDuration :: Lens' FreshnessOptions (Maybe Scientific)
foFreshnessDuration
  = lens _foFreshnessDuration
      (\ s a -> s{_foFreshnessDuration = a})
      . mapping _GDuration

-- | This property indicates the freshness level of the object in the index.
-- If set, this property must be a top-level property within the property
-- definitions and it must be a timestamp type or date type. Otherwise, the
-- Indexing API uses updateTime as the freshness indicator. The maximum
-- length is 256 characters. When a property is used to calculate
-- fresheness, the value defaults to 2 years from the current time.
foFreshnessProperty :: Lens' FreshnessOptions (Maybe Text)
foFreshnessProperty
  = lens _foFreshnessProperty
      (\ s a -> s{_foFreshnessProperty = a})

instance FromJSON FreshnessOptions where
        parseJSON
          = withObject "FreshnessOptions"
              (\ o ->
                 FreshnessOptions' <$>
                   (o .:? "freshnessDuration") <*>
                     (o .:? "freshnessProperty"))

instance ToJSON FreshnessOptions where
        toJSON FreshnessOptions'{..}
          = object
              (catMaybes
                 [("freshnessDuration" .=) <$> _foFreshnessDuration,
                  ("freshnessProperty" .=) <$> _foFreshnessProperty])

-- | Shared request debug options for all cloudsearch RPC methods.
--
-- /See:/ 'debugOptions' smart constructor.
newtype DebugOptions =
  DebugOptions'
    { _doEnableDebugging :: Maybe Bool
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'DebugOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'doEnableDebugging'
debugOptions
    :: DebugOptions
debugOptions = DebugOptions' {_doEnableDebugging = Nothing}


-- | If you are asked by Google to help with debugging, set this field.
-- Otherwise, ignore this field.
doEnableDebugging :: Lens' DebugOptions (Maybe Bool)
doEnableDebugging
  = lens _doEnableDebugging
      (\ s a -> s{_doEnableDebugging = a})

instance FromJSON DebugOptions where
        parseJSON
          = withObject "DebugOptions"
              (\ o -> DebugOptions' <$> (o .:? "enableDebugging"))

instance ToJSON DebugOptions where
        toJSON DebugOptions'{..}
          = object
              (catMaybes
                 [("enableDebugging" .=) <$> _doEnableDebugging])

-- | Options for integer properties.
--
-- /See:/ 'integerPropertyOptions' smart constructor.
data IntegerPropertyOptions =
  IntegerPropertyOptions'
    { _ipoMaximumValue    :: !(Maybe (Textual Int64))
    , _ipoOrderedRanking  :: !(Maybe IntegerPropertyOptionsOrderedRanking)
    , _ipoMinimumValue    :: !(Maybe (Textual Int64))
    , _ipoOperatorOptions :: !(Maybe IntegerOperatorOptions)
    }
  deriving (Eq, Show, Data, Typeable, Generic)


-- | Creates a value of 'IntegerPropertyOptions' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'ipoMaximumValue'
--
-- * 'ipoOrderedRanking'
--
-- * 'ipoMinimumValue'
--
-- * 'ipoOperatorOptions'
integerPropertyOptions
    :: IntegerPropertyOptions
integerPropertyOptions =
  IntegerPropertyOptions'
    { _ipoMaximumValue = Nothing
    , _ipoOrderedRanking = Nothing
    , _ipoMinimumValue = Nothing
    , _ipoOperatorOptions = Nothing
    }


-- | The maximum value of the property. The minimum and maximum values for
-- the property are used to rank results according to the ordered ranking.
-- Indexing requests with values greater than the maximum are accepted and
-- ranked with the same weight as items indexed with the maximum value.
ipoMaximumValue :: Lens' IntegerPropertyOptions (Maybe Int64)
ipoMaximumValue
  = lens _ipoMaximumValue
      (\ s a -> s{_ipoMaximumValue = a})
      . mapping _Coerce

-- | Used to specify the ordered ranking for the integer. Can only be used if
-- isRepeatable is false.
ipoOrderedRanking :: Lens' IntegerPropertyOptions (Maybe IntegerPropertyOptionsOrderedRanking)
ipoOrderedRanking
  = lens _ipoOrderedRanking
      (\ s a -> s{_ipoOrderedRanking = a})

-- | The minimum value of the property. The minimum and maximum values for
-- the property are used to rank results according to the ordered ranking.
-- Indexing requests with values less than the minimum are accepted and
-- ranked with the same weight as items indexed with the minimum value.
ipoMinimumValue :: Lens' IntegerPropertyOptions (Maybe Int64)
ipoMinimumValue
  = lens _ipoMinimumValue
      (\ s a -> s{_ipoMinimumValue = a})
      . mapping _Coerce

-- | If set, describes how the integer should be used as a search operator.
ipoOperatorOptions :: Lens' IntegerPropertyOptions (Maybe IntegerOperatorOptions)
ipoOperatorOptions
  = lens _ipoOperatorOptions
      (\ s a -> s{_ipoOperatorOptions = a})

instance FromJSON IntegerPropertyOptions where
        parseJSON
          = withObject "IntegerPropertyOptions"
              (\ o ->
                 IntegerPropertyOptions' <$>
                   (o .:? "maximumValue") <*> (o .:? "orderedRanking")
                     <*> (o .:? "minimumValue")
                     <*> (o .:? "operatorOptions"))

instance ToJSON IntegerPropertyOptions where
        toJSON IntegerPropertyOptions'{..}
          = object
              (catMaybes
                 [("maximumValue" .=) <$> _ipoMaximumValue,
                  ("orderedRanking" .=) <$> _ipoOrderedRanking,
                  ("minimumValue" .=) <$> _ipoMinimumValue,
                  ("operatorOptions" .=) <$> _ipoOperatorOptions])

-- | Restriction on Datasource.
--
-- /See:/ 'dataSourceRestriction' smart constructor.
data DataSourceRestriction =
  DataSourceRestriction'
    { _dsrFilterOptions :: !(