# 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.ServiceControl.V1.Model.V1ResourceEvent do
  @moduledoc """
  Report v2 extension proto for passing the resource metadata associated with a resource create/update/delete/undelete event from ESF to Chemist. ResourceEvent proto should be serialized into the ReportRequest.operations.extensions.

  ## Attributes

  *   `contextId` (*type:* `String.t`, *default:* `nil`) - The ESF unique context id of the api request, from which this resource event originated. This field is only needed for CAIS integration via api annotation. See go/cais-lro-delete for more details.
  *   `destinations` (*type:* `String.t`, *default:* `nil`) - The destinations field determines which backend services should handle the event. This should be specified as a comma-delimited string.
  *   `parent` (*type:* `GoogleApi.ServiceControl.V1.Model.Resource.t`, *default:* `nil`) - The parent resource for the resource.
  *   `path` (*type:* `String.t`, *default:* `nil`) - The api path the resource event was created in. This should match the source of the `payload` field. For direct integrations with Chemist, this should generally be the RESPONSE. go/resource-event-pipeline-type
  *   `payload` (*type:* `map()`, *default:* `nil`) - The payload contains metadata associated with the resource event. A ResourceEventPayloadStatus is provided instead if the original payload cannot be returned due to a limitation (e.g. size limit).
  *   `resource` (*type:* `GoogleApi.ServiceControl.V1.Model.Resource.t`, *default:* `nil`) - The resource associated with the event.
  *   `type` (*type:* `String.t`, *default:* `nil`) - The resource event type determines how the backend service should process the event.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :contextId => String.t() | nil,
          :destinations => String.t() | nil,
          :parent => GoogleApi.ServiceControl.V1.Model.Resource.t() | nil,
          :path => String.t() | nil,
          :payload => map() | nil,
          :resource => GoogleApi.ServiceControl.V1.Model.Resource.t() | nil,
          :type => String.t() | nil
        }

  field(:contextId)
  field(:destinations)
  field(:parent, as: GoogleApi.ServiceControl.V1.Model.Resource)
  field(:path)
  field(:payload, type: :map)
  field(:resource, as: GoogleApi.ServiceControl.V1.Model.Resource)
  field(:type)
end

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

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