# 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.Retail.V2.Model.GoogleCloudRetailLoggingErrorLog do
  @moduledoc """
  An error log which is reported to the Error Reporting system. This proto a superset of google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent.

  ## Attributes

  *   `context` (*type:* `GoogleApi.Retail.V2.Model.GoogleCloudRetailLoggingErrorContext.t`, *default:* `nil`) - A description of the context in which the error occurred.
  *   `importPayload` (*type:* `GoogleApi.Retail.V2.Model.GoogleCloudRetailLoggingImportErrorContext.t`, *default:* `nil`) - The error payload that is populated on LRO import APIs.
  *   `message` (*type:* `String.t`, *default:* `nil`) - A message describing the error.
  *   `requestPayload` (*type:* `map()`, *default:* `nil`) - The API request payload, represented as a protocol buffer. Most API request types are supported. For example: "type.googleapis.com/google.cloud.retail.v2.ProductService.CreateProductRequest" "type.googleapis.com/google.cloud.retail.v2.UserEventService.WriteUserEventRequest"
  *   `responsePayload` (*type:* `map()`, *default:* `nil`) - The API response payload, represented as a protocol buffer. This is used to log some "soft errors", where the response is valid but we consider there are some quality issues like unjoined events. The following API responses are supported and no PII is included: "google.cloud.retail.v2.PredictionService.Predict" "google.cloud.retail.v2.UserEventService.WriteUserEvent" "google.cloud.retail.v2.UserEventService.CollectUserEvent"
  *   `serviceContext` (*type:* `GoogleApi.Retail.V2.Model.GoogleCloudRetailLoggingServiceContext.t`, *default:* `nil`) - The service context in which this error has occurred.
  *   `status` (*type:* `GoogleApi.Retail.V2.Model.GoogleRpcStatus.t`, *default:* `nil`) - The RPC status associated with the error log.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :context => GoogleApi.Retail.V2.Model.GoogleCloudRetailLoggingErrorContext.t() | nil,
          :importPayload =>
            GoogleApi.Retail.V2.Model.GoogleCloudRetailLoggingImportErrorContext.t() | nil,
          :message => String.t() | nil,
          :requestPayload => map() | nil,
          :responsePayload => map() | nil,
          :serviceContext =>
            GoogleApi.Retail.V2.Model.GoogleCloudRetailLoggingServiceContext.t() | nil,
          :status => GoogleApi.Retail.V2.Model.GoogleRpcStatus.t() | nil
        }

  field(:context, as: GoogleApi.Retail.V2.Model.GoogleCloudRetailLoggingErrorContext)
  field(:importPayload, as: GoogleApi.Retail.V2.Model.GoogleCloudRetailLoggingImportErrorContext)
  field(:message)
  field(:requestPayload, type: :map)
  field(:responsePayload, type: :map)
  field(:serviceContext, as: GoogleApi.Retail.V2.Model.GoogleCloudRetailLoggingServiceContext)
  field(:status, as: GoogleApi.Retail.V2.Model.GoogleRpcStatus)
end

defimpl Poison.Decoder, for: GoogleApi.Retail.V2.Model.GoogleCloudRetailLoggingErrorLog do
  def decode(value, options) do
    GoogleApi.Retail.V2.Model.GoogleCloudRetailLoggingErrorLog.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Retail.V2.Model.GoogleCloudRetailLoggingErrorLog do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
