# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.CloudSearch.V1.Model.SearchRequest do
  @moduledoc """
  The search API request. NEXT ID: 17

  ## Attributes

  *   `contextAttributes` (*type:* `list(GoogleApi.CloudSearch.V1.Model.ContextAttribute.t)`, *default:* `nil`) - Context attributes for the request which will be used to adjust ranking of search results. The maximum number of elements is 10.
  *   `dataSourceRestrictions` (*type:* `list(GoogleApi.CloudSearch.V1.Model.DataSourceRestriction.t)`, *default:* `nil`) - The sources to use for querying. If not specified, all data sources from the current search application are used.
  *   `facetOptions` (*type:* `list(GoogleApi.CloudSearch.V1.Model.FacetOptions.t)`, *default:* `nil`) - 
  *   `pageSize` (*type:* `integer()`, *default:* `nil`) - Maximum number of search results to return in one page. Valid values are between 1 and 100, inclusive. Default value is 10. Minimum value is 50 when results beyond 2000 are requested.
  *   `query` (*type:* `String.t`, *default:* `nil`) - The raw query string. See supported search operators in the [Narrow your search with operators](https://support.google.com/cloudsearch/answer/6172299)
  *   `queryInterpretationOptions` (*type:* `GoogleApi.CloudSearch.V1.Model.QueryInterpretationOptions.t`, *default:* `nil`) - Options to interpret the user query.
  *   `requestOptions` (*type:* `GoogleApi.CloudSearch.V1.Model.RequestOptions.t`, *default:* `nil`) - Request options, such as the search application and user timezone.
  *   `sortOptions` (*type:* `GoogleApi.CloudSearch.V1.Model.SortOptions.t`, *default:* `nil`) - The options for sorting the search results
  *   `start` (*type:* `integer()`, *default:* `nil`) - Starting index of the results.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :contextAttributes => list(GoogleApi.CloudSearch.V1.Model.ContextAttribute.t()) | nil,
          :dataSourceRestrictions =>
            list(GoogleApi.CloudSearch.V1.Model.DataSourceRestriction.t()) | nil,
          :facetOptions => list(GoogleApi.CloudSearch.V1.Model.FacetOptions.t()) | nil,
          :pageSize => integer() | nil,
          :query => String.t() | nil,
          :queryInterpretationOptions =>
            GoogleApi.CloudSearch.V1.Model.QueryInterpretationOptions.t() | nil,
          :requestOptions => GoogleApi.CloudSearch.V1.Model.RequestOptions.t() | nil,
          :sortOptions => GoogleApi.CloudSearch.V1.Model.SortOptions.t() | nil,
          :start => integer() | nil
        }

  field(:contextAttributes, as: GoogleApi.CloudSearch.V1.Model.ContextAttribute, type: :list)

  field(:dataSourceRestrictions,
    as: GoogleApi.CloudSearch.V1.Model.DataSourceRestriction,
    type: :list
  )

  field(:facetOptions, as: GoogleApi.CloudSearch.V1.Model.FacetOptions, type: :list)
  field(:pageSize)
  field(:query)

  field(:queryInterpretationOptions, as: GoogleApi.CloudSearch.V1.Model.QueryInterpretationOptions)

  field(:requestOptions, as: GoogleApi.CloudSearch.V1.Model.RequestOptions)
  field(:sortOptions, as: GoogleApi.CloudSearch.V1.Model.SortOptions)
  field(:start)
end

defimpl Poison.Decoder, for: GoogleApi.CloudSearch.V1.Model.SearchRequest do
  def decode(value, options) do
    GoogleApi.CloudSearch.V1.Model.SearchRequest.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.CloudSearch.V1.Model.SearchRequest do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
