# 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.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4ThreatEntrySet do
  @moduledoc """
  A set of threats that should be added or removed from a client's local database.

  ## Attributes

  *   `compressionType` (*type:* `String.t`, *default:* `nil`) - The compression type for the entries in this set.
  *   `rawHashes` (*type:* `GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4RawHashes.t`, *default:* `nil`) - The raw SHA256-formatted entries.
  *   `rawIndices` (*type:* `GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4RawIndices.t`, *default:* `nil`) - The raw removal indices for a local list.
  *   `riceHashes` (*type:* `GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4RiceDeltaEncoding.t`, *default:* `nil`) - The encoded 4-byte prefixes of SHA256-formatted entries, using a Golomb-Rice encoding. The hashes are converted to uint32, sorted in ascending order, then delta encoded and stored as encoded_data.
  *   `riceIndices` (*type:* `GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4RiceDeltaEncoding.t`, *default:* `nil`) - The encoded local, lexicographically-sorted list indices, using a Golomb-Rice encoding. Used for sending compressed removal indices. The removal indices (uint32) are sorted in ascending order, then delta encoded and stored as encoded_data.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :compressionType => String.t() | nil,
          :rawHashes =>
            GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4RawHashes.t() | nil,
          :rawIndices =>
            GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4RawIndices.t() | nil,
          :riceHashes =>
            GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4RiceDeltaEncoding.t()
            | nil,
          :riceIndices =>
            GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4RiceDeltaEncoding.t()
            | nil
        }

  field(:compressionType)
  field(:rawHashes, as: GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4RawHashes)
  field(:rawIndices, as: GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4RawIndices)

  field(:riceHashes,
    as: GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4RiceDeltaEncoding
  )

  field(:riceIndices,
    as: GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4RiceDeltaEncoding
  )
end

defimpl Poison.Decoder,
  for: GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4ThreatEntrySet do
  def decode(value, options) do
    GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4ThreatEntrySet.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.SafeBrowsing.V4.Model.GoogleSecuritySafebrowsingV4ThreatEntrySet do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
