# frozen_string_literal: true

# Copyright 2021 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
#
#     https://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.

# Auto-generated by gapic-generator-ruby. DO NOT EDIT!


module Google
  module Devtools
    module Remoteworkers
      module V1test2
        # Describes a shell-style task to execute, suitable for providing as the Bots
        # interface's `Lease.payload` field.
        # @!attribute [rw] inputs
        #   @return [::Google::Devtools::Remoteworkers::V1test2::CommandTask::Inputs]
        #     The inputs to the task.
        # @!attribute [rw] expected_outputs
        #   @return [::Google::Devtools::Remoteworkers::V1test2::CommandTask::Outputs]
        #     The expected outputs from the task.
        # @!attribute [rw] timeouts
        #   @return [::Google::Devtools::Remoteworkers::V1test2::CommandTask::Timeouts]
        #     The timeouts of this task.
        class CommandTask
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods

          # Describes the inputs to a shell-style task.
          # @!attribute [rw] arguments
          #   @return [::Array<::String>]
          #     The command itself to run (e.g., argv).
          #
          #     This field should be passed directly to the underlying operating system,
          #     and so it must be sensible to that operating system. For example, on
          #     Windows, the first argument might be "C:\Windows\System32\ping.exe" -
          #     that is, using drive letters and backslashes. A command for a *nix
          #     system, on the other hand, would use forward slashes.
          #
          #     All other fields in the RWAPI must consistently use forward slashes,
          #     since those fields may be interpretted by both the service and the bot.
          # @!attribute [rw] files
          #   @return [::Array<::Google::Devtools::Remoteworkers::V1test2::Digest>]
          #     The input filesystem to be set up prior to the task beginning. The
          #     contents should be a repeated set of FileMetadata messages though other
          #     formats are allowed if better for the implementation (eg, a LUCI-style
          #     .isolated file).
          #
          #     This field is repeated since implementations might want to cache the
          #     metadata, in which case it may be useful to break up portions of the
          #     filesystem that change frequently (eg, specific input files) from those
          #     that don't (eg, standard header files).
          # @!attribute [rw] inline_blobs
          #   @return [::Array<::Google::Devtools::Remoteworkers::V1test2::Blob>]
          #     Inline contents for blobs expected to be needed by the bot to execute the
          #     task. For example, contents of entries in `files` or blobs that are
          #     indirectly referenced by an entry there.
          #
          #     The bot should check against this list before downloading required task
          #     inputs to reduce the number of communications between itself and the
          #     remote CAS server.
          # @!attribute [rw] environment_variables
          #   @return [::Array<::Google::Devtools::Remoteworkers::V1test2::CommandTask::Inputs::EnvironmentVariable>]
          #     All environment variables required by the task.
          # @!attribute [rw] working_directory
          #   @return [::String]
          #     Directory from which a command is executed. It is a relative directory
          #     with respect to the bot's working directory (i.e., "./"). If it is
          #     non-empty, then it must exist under "./". Otherwise, "./" will be used.
          class Inputs
            include ::Google::Protobuf::MessageExts
            extend ::Google::Protobuf::MessageExts::ClassMethods

            # An environment variable required by this task.
            # @!attribute [rw] name
            #   @return [::String]
            #     The envvar name.
            # @!attribute [rw] value
            #   @return [::String]
            #     The envvar value.
            class EnvironmentVariable
              include ::Google::Protobuf::MessageExts
              extend ::Google::Protobuf::MessageExts::ClassMethods
            end
          end

          # Describes the expected outputs of the command.
          # @!attribute [rw] files
          #   @return [::Array<::String>]
          #     A list of expected files, relative to the execution root. All paths
          #     MUST be delimited by forward slashes.
          # @!attribute [rw] directories
          #   @return [::Array<::String>]
          #     A list of expected directories, relative to the execution root. All paths
          #     MUST be delimited by forward slashes.
          # @!attribute [rw] stdout_destination
          #   @return [::String]
          #     The destination to which any stdout should be sent. The method by which
          #     the bot should send the stream contents to that destination is not
          #     defined in this API. As examples, the destination could be a file
          #     referenced in the `files` field in this message, or it could be a URI
          #     that must be written via the ByteStream API.
          # @!attribute [rw] stderr_destination
          #   @return [::String]
          #     The destination to which any stderr should be sent. The method by which
          #     the bot should send the stream contents to that destination is not
          #     defined in this API. As examples, the destination could be a file
          #     referenced in the `files` field in this message, or it could be a URI
          #     that must be written via the ByteStream API.
          class Outputs
            include ::Google::Protobuf::MessageExts
            extend ::Google::Protobuf::MessageExts::ClassMethods
          end

          # Describes the timeouts associated with this task.
          # @!attribute [rw] execution
          #   @return [::Google::Protobuf::Duration]
          #     This specifies the maximum time that the task can run, excluding the
          #     time required to download inputs or upload outputs. That is, the worker
          #     will terminate the task if it runs longer than this.
          # @!attribute [rw] idle
          #   @return [::Google::Protobuf::Duration]
          #     This specifies the maximum amount of time the task can be idle - that is,
          #     go without generating some output in either stdout or stderr. If the
          #     process is silent for more than the specified time, the worker will
          #     terminate the task.
          # @!attribute [rw] shutdown
          #   @return [::Google::Protobuf::Duration]
          #     If the execution or IO timeouts are exceeded, the worker will try to
          #     gracefully terminate the task and return any existing logs. However,
          #     tasks may be hard-frozen in which case this process will fail. This
          #     timeout specifies how long to wait for a terminated task to shut down
          #     gracefully (e.g. via SIGTERM) before we bring down the hammer (e.g.
          #     SIGKILL on *nix, CTRL_BREAK_EVENT on Windows).
          class Timeouts
            include ::Google::Protobuf::MessageExts
            extend ::Google::Protobuf::MessageExts::ClassMethods
          end
        end

        # DEPRECATED - use CommandResult instead.
        # Describes the actual outputs from the task.
        # @!attribute [rw] exit_code
        #   @return [::Integer]
        #     exit_code is only fully reliable if the status' code is OK. If the task
        #     exceeded its deadline or was cancelled, the process may still produce an
        #     exit code as it is cancelled, and this will be populated, but a successful
        #     (zero) is unlikely to be correct unless the status code is OK.
        # @!attribute [rw] outputs
        #   @return [::Google::Devtools::Remoteworkers::V1test2::Digest]
        #     The output files. The blob referenced by the digest should contain
        #     one of the following (implementation-dependent):
        #        * A marshalled DirectoryMetadata of the returned filesystem
        #        * A LUCI-style .isolated file
        class CommandOutputs
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # DEPRECATED - use CommandResult instead.
        # Can be used as part of CompleteRequest.metadata, or are part of a more
        # sophisticated message.
        # @!attribute [rw] duration
        #   @return [::Google::Protobuf::Duration]
        #     The elapsed time between calling Accept and Complete. The server will also
        #     have its own idea of what this should be, but this excludes the overhead of
        #     the RPCs and the bot response time.
        # @!attribute [rw] overhead
        #   @return [::Google::Protobuf::Duration]
        #     The amount of time *not* spent executing the command (ie
        #     uploading/downloading files).
        class CommandOverhead
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # All information about the execution of a command, suitable for providing as
        # the Bots interface's `Lease.result` field.
        # @!attribute [rw] status
        #   @return [::Google::Rpc::Status]
        #     An overall status for the command. For example, if the command timed out,
        #     this might have a code of DEADLINE_EXCEEDED; if it was killed by the OS for
        #     memory exhaustion, it might have a code of RESOURCE_EXHAUSTED.
        # @!attribute [rw] exit_code
        #   @return [::Integer]
        #     The exit code of the process. An exit code of "0" should only be trusted if
        #     `status` has a code of OK (otherwise it may simply be unset).
        # @!attribute [rw] outputs
        #   @return [::Google::Devtools::Remoteworkers::V1test2::Digest]
        #     The output files. The blob referenced by the digest should contain
        #     one of the following (implementation-dependent):
        #        * A marshalled DirectoryMetadata of the returned filesystem
        #        * A LUCI-style .isolated file
        # @!attribute [rw] duration
        #   @return [::Google::Protobuf::Duration]
        #     The elapsed time between calling Accept and Complete. The server will also
        #     have its own idea of what this should be, but this excludes the overhead of
        #     the RPCs and the bot response time.
        # @!attribute [rw] overhead
        #   @return [::Google::Protobuf::Duration]
        #     The amount of time *not* spent executing the command (ie
        #     uploading/downloading files).
        # @!attribute [rw] metadata
        #   @return [::Array<::Google::Protobuf::Any>]
        #     Implementation-dependent metadata about the task. Both servers and bots
        #     may define messages which can be encoded here; bots are free to provide
        #     metadata in multiple formats, and servers are free to choose one or more
        #     of the values to process and ignore others. In particular, it is *not*
        #     considered an error for the bot to provide the server with a field that it
        #     doesn't know about.
        class CommandResult
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # The metadata for a file. Similar to the equivalent message in the Remote
        # Execution API.
        # @!attribute [rw] path
        #   @return [::String]
        #     The path of this file. If this message is part of the
        #     CommandOutputs.outputs fields, the path is relative to the execution root
        #     and must correspond to an entry in CommandTask.outputs.files. If this
        #     message is part of a Directory message, then the path is relative to the
        #     root of that directory. All paths MUST be delimited by forward slashes.
        # @!attribute [rw] digest
        #   @return [::Google::Devtools::Remoteworkers::V1test2::Digest]
        #     A pointer to the contents of the file. The method by which a client
        #     retrieves the contents from a CAS system is not defined here.
        # @!attribute [rw] contents
        #   @return [::String]
        #     If the file is small enough, its contents may also or alternatively be
        #     listed here.
        # @!attribute [rw] is_executable
        #   @return [::Boolean]
        #     Properties of the file
        class FileMetadata
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # The metadata for a directory. Similar to the equivalent message in the Remote
        # Execution API.
        # @!attribute [rw] path
        #   @return [::String]
        #     The path of the directory, as in
        #     {::Google::Devtools::Remoteworkers::V1test2::FileMetadata#path FileMetadata.path}.
        # @!attribute [rw] digest
        #   @return [::Google::Devtools::Remoteworkers::V1test2::Digest]
        #     A pointer to the contents of the directory, in the form of a marshalled
        #     Directory message.
        class DirectoryMetadata
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # The CommandTask and CommandResult messages assume the existence of a service
        # that can serve blobs of content, identified by a hash and size known as a
        # "digest." The method by which these blobs may be retrieved is not specified
        # here, but a model implementation is in the Remote Execution API's
        # "ContentAddressibleStorage" interface.
        #
        # In the context of the RWAPI, a Digest will virtually always refer to the
        # contents of a file or a directory. The latter is represented by the
        # byte-encoded Directory message.
        # @!attribute [rw] hash
        #   @return [::String]
        #     A string-encoded hash (eg "1a2b3c", not the byte array [0x1a, 0x2b, 0x3c])
        #     using an implementation-defined hash algorithm (eg SHA-256).
        # @!attribute [rw] size_bytes
        #   @return [::Integer]
        #     The size of the contents. While this is not strictly required as part of an
        #     identifier (after all, any given hash will have exactly one canonical
        #     size), it's useful in almost all cases when one might want to send or
        #     retrieve blobs of content and is included here for this reason.
        class Digest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Describes a blob of binary content with its digest.
        # @!attribute [rw] digest
        #   @return [::Google::Devtools::Remoteworkers::V1test2::Digest]
        #     The digest of the blob. This should be verified by the receiver.
        # @!attribute [rw] contents
        #   @return [::String]
        #     The contents of the blob.
        class Blob
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # The contents of a directory. Similar to the equivalent message in the Remote
        # Execution API.
        # @!attribute [rw] files
        #   @return [::Array<::Google::Devtools::Remoteworkers::V1test2::FileMetadata>]
        #     The files in this directory
        # @!attribute [rw] directories
        #   @return [::Array<::Google::Devtools::Remoteworkers::V1test2::DirectoryMetadata>]
        #     Any subdirectories
        class Directory
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end
      end
    end
  end
end
