# 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.RemoteBuildExecution.V2.Model.BuildBazelRemoteExecutionV2ExecuteResponse do
  @moduledoc """
  The response message for Execution.Execute, which will be contained in the response field of the Operation.

  ## Attributes

  *   `cachedResult` (*type:* `boolean()`, *default:* `nil`) - True if the result was served from cache, false if it was executed.
  *   `message` (*type:* `String.t`, *default:* `nil`) - Freeform informational message with details on the execution of the action that may be displayed to the user upon failure or when requested explicitly.
  *   `result` (*type:* `GoogleApi.RemoteBuildExecution.V2.Model.BuildBazelRemoteExecutionV2ActionResult.t`, *default:* `nil`) - The result of the action.
  *   `serverLogs` (*type:* `%{optional(String.t) => GoogleApi.RemoteBuildExecution.V2.Model.BuildBazelRemoteExecutionV2LogFile.t}`, *default:* `nil`) - An optional list of additional log outputs the server wishes to provide. A server can use this to return execution-specific logs however it wishes. This is intended primarily to make it easier for users to debug issues that may be outside of the actual job execution, such as by identifying the worker executing the action or by providing logs from the worker's setup phase. The keys SHOULD be human readable so that a client can display them to a user.
  *   `status` (*type:* `GoogleApi.RemoteBuildExecution.V2.Model.GoogleRpcStatus.t`, *default:* `nil`) - If the status has a code other than `OK`, it indicates that the action did not finish execution. For example, if the operation times out during execution, the status will have a `DEADLINE_EXCEEDED` code. Servers MUST use this field for errors in execution, rather than the error field on the `Operation` object. If the status code is other than `OK`, then the result MUST NOT be cached. For an error status, the `result` field is optional; the server may populate the output-, stdout-, and stderr-related fields if it has any information available, such as the stdout and stderr of a timed-out action.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :cachedResult => boolean() | nil,
          :message => String.t() | nil,
          :result =>
            GoogleApi.RemoteBuildExecution.V2.Model.BuildBazelRemoteExecutionV2ActionResult.t()
            | nil,
          :serverLogs =>
            %{
              optional(String.t()) =>
                GoogleApi.RemoteBuildExecution.V2.Model.BuildBazelRemoteExecutionV2LogFile.t()
            }
            | nil,
          :status => GoogleApi.RemoteBuildExecution.V2.Model.GoogleRpcStatus.t() | nil
        }

  field(:cachedResult)
  field(:message)

  field(:result,
    as: GoogleApi.RemoteBuildExecution.V2.Model.BuildBazelRemoteExecutionV2ActionResult
  )

  field(:serverLogs,
    as: GoogleApi.RemoteBuildExecution.V2.Model.BuildBazelRemoteExecutionV2LogFile,
    type: :map
  )

  field(:status, as: GoogleApi.RemoteBuildExecution.V2.Model.GoogleRpcStatus)
end

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

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