# 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.Api.Stats do
  @moduledoc """
  API calls for all endpoints tagged `Stats`.
  """

  alias GoogleApi.CloudSearch.V1.Connection
  alias GoogleApi.Gax.{Request, Response}

  @library_version Mix.Project.config() |> Keyword.get(:version, "")

  @doc """
  Gets indexed item statistics aggreggated across all data sources. This API only returns statistics for previous dates; it doesn't return statistics for the current day. **Note:** This API requires a standard end user account to execute.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
      *   `:access_token` (*type:* `String.t`) - OAuth access token.
      *   `:alt` (*type:* `String.t`) - Data format for response.
      *   `:callback` (*type:* `String.t`) - JSONP
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
      *   `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
      *   `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
      *   `:"fromDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"fromDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"fromDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
      *   `:"toDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"toDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"toDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.CloudSearch.V1.Model.GetCustomerIndexStatsResponse{}}` on success
  *   `{:error, info}` on failure
  """
  @spec cloudsearch_stats_get_index(Tesla.Env.client(), keyword(), keyword()) ::
          {:ok, GoogleApi.CloudSearch.V1.Model.GetCustomerIndexStatsResponse.t()}
          | {:ok, Tesla.Env.t()}
          | {:ok, list()}
          | {:error, any()}
  def cloudsearch_stats_get_index(connection, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :uploadType => :query,
      :upload_protocol => :query,
      :"fromDate.day" => :query,
      :"fromDate.month" => :query,
      :"fromDate.year" => :query,
      :"toDate.day" => :query,
      :"toDate.month" => :query,
      :"toDate.year" => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/v1/stats/index", %{})
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(
      opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.GetCustomerIndexStatsResponse{}]
    )
  end

  @doc """
  Get the query statistics for customer. **Note:** This API requires a standard end user account to execute.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
      *   `:access_token` (*type:* `String.t`) - OAuth access token.
      *   `:alt` (*type:* `String.t`) - Data format for response.
      *   `:callback` (*type:* `String.t`) - JSONP
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
      *   `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
      *   `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
      *   `:"fromDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"fromDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"fromDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
      *   `:"toDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"toDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"toDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.CloudSearch.V1.Model.GetCustomerQueryStatsResponse{}}` on success
  *   `{:error, info}` on failure
  """
  @spec cloudsearch_stats_get_query(Tesla.Env.client(), keyword(), keyword()) ::
          {:ok, GoogleApi.CloudSearch.V1.Model.GetCustomerQueryStatsResponse.t()}
          | {:ok, Tesla.Env.t()}
          | {:ok, list()}
          | {:error, any()}
  def cloudsearch_stats_get_query(connection, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :uploadType => :query,
      :upload_protocol => :query,
      :"fromDate.day" => :query,
      :"fromDate.month" => :query,
      :"fromDate.year" => :query,
      :"toDate.day" => :query,
      :"toDate.month" => :query,
      :"toDate.year" => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/v1/stats/query", %{})
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(
      opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.GetCustomerQueryStatsResponse{}]
    )
  end

  @doc """
  Get search application stats for customer. **Note:** This API requires a standard end user account to execute.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
      *   `:access_token` (*type:* `String.t`) - OAuth access token.
      *   `:alt` (*type:* `String.t`) - Data format for response.
      *   `:callback` (*type:* `String.t`) - JSONP
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
      *   `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
      *   `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
      *   `:"endDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"endDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"endDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
      *   `:"startDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"startDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"startDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.CloudSearch.V1.Model.GetCustomerSearchApplicationStatsResponse{}}` on success
  *   `{:error, info}` on failure
  """
  @spec cloudsearch_stats_get_searchapplication(Tesla.Env.client(), keyword(), keyword()) ::
          {:ok, GoogleApi.CloudSearch.V1.Model.GetCustomerSearchApplicationStatsResponse.t()}
          | {:ok, Tesla.Env.t()}
          | {:ok, list()}
          | {:error, any()}
  def cloudsearch_stats_get_searchapplication(connection, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :uploadType => :query,
      :upload_protocol => :query,
      :"endDate.day" => :query,
      :"endDate.month" => :query,
      :"endDate.year" => :query,
      :"startDate.day" => :query,
      :"startDate.month" => :query,
      :"startDate.year" => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/v1/stats/searchapplication", %{})
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(
      opts ++
        [struct: %GoogleApi.CloudSearch.V1.Model.GetCustomerSearchApplicationStatsResponse{}]
    )
  end

  @doc """
  Get the # of search sessions, % of successful sessions with a click query statistics for customer. **Note:** This API requires a standard end user account to execute.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
      *   `:access_token` (*type:* `String.t`) - OAuth access token.
      *   `:alt` (*type:* `String.t`) - Data format for response.
      *   `:callback` (*type:* `String.t`) - JSONP
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
      *   `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
      *   `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
      *   `:"fromDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"fromDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"fromDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
      *   `:"toDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"toDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"toDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.CloudSearch.V1.Model.GetCustomerSessionStatsResponse{}}` on success
  *   `{:error, info}` on failure
  """
  @spec cloudsearch_stats_get_session(Tesla.Env.client(), keyword(), keyword()) ::
          {:ok, GoogleApi.CloudSearch.V1.Model.GetCustomerSessionStatsResponse.t()}
          | {:ok, Tesla.Env.t()}
          | {:ok, list()}
          | {:error, any()}
  def cloudsearch_stats_get_session(connection, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :uploadType => :query,
      :upload_protocol => :query,
      :"fromDate.day" => :query,
      :"fromDate.month" => :query,
      :"fromDate.year" => :query,
      :"toDate.day" => :query,
      :"toDate.month" => :query,
      :"toDate.year" => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/v1/stats/session", %{})
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(
      opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.GetCustomerSessionStatsResponse{}]
    )
  end

  @doc """
  Get the users statistics for customer. **Note:** This API requires a standard end user account to execute.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
      *   `:access_token` (*type:* `String.t`) - OAuth access token.
      *   `:alt` (*type:* `String.t`) - Data format for response.
      *   `:callback` (*type:* `String.t`) - JSONP
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
      *   `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
      *   `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
      *   `:"fromDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"fromDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"fromDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
      *   `:"toDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"toDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"toDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.CloudSearch.V1.Model.GetCustomerUserStatsResponse{}}` on success
  *   `{:error, info}` on failure
  """
  @spec cloudsearch_stats_get_user(Tesla.Env.client(), keyword(), keyword()) ::
          {:ok, GoogleApi.CloudSearch.V1.Model.GetCustomerUserStatsResponse.t()}
          | {:ok, Tesla.Env.t()}
          | {:ok, list()}
          | {:error, any()}
  def cloudsearch_stats_get_user(connection, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :uploadType => :query,
      :upload_protocol => :query,
      :"fromDate.day" => :query,
      :"fromDate.month" => :query,
      :"fromDate.year" => :query,
      :"toDate.day" => :query,
      :"toDate.month" => :query,
      :"toDate.year" => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/v1/stats/user", %{})
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(
      opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.GetCustomerUserStatsResponse{}]
    )
  end

  @doc """
  Gets indexed item statistics for a single data source. **Note:** This API requires a standard end user account to execute.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
  *   `name` (*type:* `String.t`) - The resource id of the data source to retrieve statistics for, in the following format: "datasources/{source_id}"
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
      *   `:access_token` (*type:* `String.t`) - OAuth access token.
      *   `:alt` (*type:* `String.t`) - Data format for response.
      *   `:callback` (*type:* `String.t`) - JSONP
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
      *   `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
      *   `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
      *   `:"fromDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"fromDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"fromDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
      *   `:"toDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"toDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"toDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.CloudSearch.V1.Model.GetDataSourceIndexStatsResponse{}}` on success
  *   `{:error, info}` on failure
  """
  @spec cloudsearch_stats_index_datasources_get(
          Tesla.Env.client(),
          String.t(),
          keyword(),
          keyword()
        ) ::
          {:ok, GoogleApi.CloudSearch.V1.Model.GetDataSourceIndexStatsResponse.t()}
          | {:ok, Tesla.Env.t()}
          | {:ok, list()}
          | {:error, any()}
  def cloudsearch_stats_index_datasources_get(connection, name, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :uploadType => :query,
      :upload_protocol => :query,
      :"fromDate.day" => :query,
      :"fromDate.month" => :query,
      :"fromDate.year" => :query,
      :"toDate.day" => :query,
      :"toDate.month" => :query,
      :"toDate.year" => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/v1/stats/index/{+name}", %{
        "name" => URI.encode(name, &URI.char_unreserved?/1)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(
      opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.GetDataSourceIndexStatsResponse{}]
    )
  end

  @doc """
  Get the query statistics for search application. **Note:** This API requires a standard end user account to execute.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
  *   `name` (*type:* `String.t`) - The resource id of the search application query stats, in the following format: searchapplications/{application_id}
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
      *   `:access_token` (*type:* `String.t`) - OAuth access token.
      *   `:alt` (*type:* `String.t`) - Data format for response.
      *   `:callback` (*type:* `String.t`) - JSONP
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
      *   `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
      *   `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
      *   `:"fromDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"fromDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"fromDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
      *   `:"toDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"toDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"toDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.CloudSearch.V1.Model.GetSearchApplicationQueryStatsResponse{}}` on success
  *   `{:error, info}` on failure
  """
  @spec cloudsearch_stats_query_searchapplications_get(
          Tesla.Env.client(),
          String.t(),
          keyword(),
          keyword()
        ) ::
          {:ok, GoogleApi.CloudSearch.V1.Model.GetSearchApplicationQueryStatsResponse.t()}
          | {:ok, Tesla.Env.t()}
          | {:ok, list()}
          | {:error, any()}
  def cloudsearch_stats_query_searchapplications_get(
        connection,
        name,
        optional_params \\ [],
        opts \\ []
      ) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :uploadType => :query,
      :upload_protocol => :query,
      :"fromDate.day" => :query,
      :"fromDate.month" => :query,
      :"fromDate.year" => :query,
      :"toDate.day" => :query,
      :"toDate.month" => :query,
      :"toDate.year" => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/v1/stats/query/{+name}", %{
        "name" => URI.encode(name, &URI.char_unreserved?/1)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(
      opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.GetSearchApplicationQueryStatsResponse{}]
    )
  end

  @doc """
  Get the # of search sessions, % of successful sessions with a click query statistics for search application. **Note:** This API requires a standard end user account to execute.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
  *   `name` (*type:* `String.t`) - The resource id of the search application session stats, in the following format: searchapplications/{application_id}
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
      *   `:access_token` (*type:* `String.t`) - OAuth access token.
      *   `:alt` (*type:* `String.t`) - Data format for response.
      *   `:callback` (*type:* `String.t`) - JSONP
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
      *   `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
      *   `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
      *   `:"fromDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"fromDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"fromDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
      *   `:"toDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"toDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"toDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.CloudSearch.V1.Model.GetSearchApplicationSessionStatsResponse{}}` on success
  *   `{:error, info}` on failure
  """
  @spec cloudsearch_stats_session_searchapplications_get(
          Tesla.Env.client(),
          String.t(),
          keyword(),
          keyword()
        ) ::
          {:ok, GoogleApi.CloudSearch.V1.Model.GetSearchApplicationSessionStatsResponse.t()}
          | {:ok, Tesla.Env.t()}
          | {:ok, list()}
          | {:error, any()}
  def cloudsearch_stats_session_searchapplications_get(
        connection,
        name,
        optional_params \\ [],
        opts \\ []
      ) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :uploadType => :query,
      :upload_protocol => :query,
      :"fromDate.day" => :query,
      :"fromDate.month" => :query,
      :"fromDate.year" => :query,
      :"toDate.day" => :query,
      :"toDate.month" => :query,
      :"toDate.year" => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/v1/stats/session/{+name}", %{
        "name" => URI.encode(name, &URI.char_unreserved?/1)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(
      opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.GetSearchApplicationSessionStatsResponse{}]
    )
  end

  @doc """
  Get the users statistics for search application. **Note:** This API requires a standard end user account to execute.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
  *   `name` (*type:* `String.t`) - The resource id of the search application session stats, in the following format: searchapplications/{application_id}
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
      *   `:access_token` (*type:* `String.t`) - OAuth access token.
      *   `:alt` (*type:* `String.t`) - Data format for response.
      *   `:callback` (*type:* `String.t`) - JSONP
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
      *   `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
      *   `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
      *   `:"fromDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"fromDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"fromDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
      *   `:"toDate.day"` (*type:* `integer()`) - Day of month. Must be from 1 to 31 and valid for the year and month.
      *   `:"toDate.month"` (*type:* `integer()`) - Month of date. Must be from 1 to 12.
      *   `:"toDate.year"` (*type:* `integer()`) - Year of date. Must be from 1 to 9999.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.CloudSearch.V1.Model.GetSearchApplicationUserStatsResponse{}}` on success
  *   `{:error, info}` on failure
  """
  @spec cloudsearch_stats_user_searchapplications_get(
          Tesla.Env.client(),
          String.t(),
          keyword(),
          keyword()
        ) ::
          {:ok, GoogleApi.CloudSearch.V1.Model.GetSearchApplicationUserStatsResponse.t()}
          | {:ok, Tesla.Env.t()}
          | {:ok, list()}
          | {:error, any()}
  def cloudsearch_stats_user_searchapplications_get(
        connection,
        name,
        optional_params \\ [],
        opts \\ []
      ) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :uploadType => :query,
      :upload_protocol => :query,
      :"fromDate.day" => :query,
      :"fromDate.month" => :query,
      :"fromDate.year" => :query,
      :"toDate.day" => :query,
      :"toDate.month" => :query,
      :"toDate.year" => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/v1/stats/user/{+name}", %{
        "name" => URI.encode(name, &URI.char_unreserved?/1)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(
      opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.GetSearchApplicationUserStatsResponse{}]
    )
  end
end
