# 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
#
#     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.


module Google
  module Cloud
    module Irm
      module V1alpha2
        # A user of the IRM app.
        # @!attribute [rw] user_id
        #   @return [String]
        #     Output only. User id that will allow to get additional information from
        #     People API. This field will be populated implicitly if the caller creates
        #     or edits a resource (for example, posts an annotation).
        # @!attribute [rw] email
        #   @return [String]
        #     Email address of the user. This must be associated with a Google account.
        #     This field will be set if the user is explicitly identified (verbatim) by
        #     email address in an API request (potentially sometime in the past). It
        #     will not be populated based on the credentials of a caller of the API.
        class User; end

        # A signal is a message calling attention to a (potential) incident. An example
        # is a page based on a Stackdriver Alerting policy.
        # @!attribute [rw] name
        #   @return [String]
        #     Resource name of the signal, for example,
        #     "projects/{project_id}/signals/{signal_id}".
        # @!attribute [rw] etag
        #   @return [String]
        #     Etag to validate the object is unchanged for a read-modify-write operation.
        #     An empty etag will overwrite other changes.
        # @!attribute [rw] incident
        #   @return [String]
        #     Resource name of the incident this signal is currently assigned to.
        #     May be empty if signal is unassigned.
        # @!attribute [rw] create_time
        #   @return [Google::Protobuf::Timestamp]
        #     Output only. Time this signal was created.
        # @!attribute [rw] close_time
        #   @return [Google::Protobuf::Timestamp]
        #     Output only. Time this signal was closed. This field is not populated
        #     while the signal is still firing.
        # @!attribute [rw] detect_time
        #   @return [Google::Protobuf::Timestamp]
        #     The time this Signal was first detected. This is identical to create_time
        #     for Signals created by Stackdriver Alerting.
        # @!attribute [rw] creator
        #   @return [Google::Cloud::Irm::V1alpha2::User]
        #     Output only. The user that created this signal for manually created
        #     signals. Empty if this signal was generated by a system (for example,
        #     Stackdriver Alerting).
        # @!attribute [rw] title
        #   @return [String]
        #     One-line summary of the signal.
        #     Immutable.
        # @!attribute [rw] content_type
        #   @return [String]
        #     Content type string. 'text/plain' is currently the only supported content
        #     type for Signals created via the API. Signals created by Stackdriver
        #     Alerting support 'text/html' as well. Immutable for Signals created by
        #     Stackdriver Alerting.
        # @!attribute [rw] content
        #   @return [String]
        #     Full message of the signal.
        #     Immutable for Signals created by Stackdriver Alerting.
        # @!attribute [rw] signal_state
        #   @return [Google::Cloud::Irm::V1alpha2::Signal::State]
        #     The state of this signal.
        #     For Signals created by Stackdriver Alerting this field is output only.
        # @!attribute [rw] signal_artifacts
        #   @return [Array<Google::Cloud::Irm::V1alpha2::Signal::SignalArtifact>]
        #     A set of artifacts to additional resources for this Signal. For example, a
        #     link to Stackdriver logging for the Signal.
        #     Immutable for Signals created by Stackdriver Alerting.
        class Signal
          # An artifact associated with the Signal.
          # @!attribute [rw] user_type
          #   @return [String]
          #     A custom user type
          # @!attribute [rw] uri
          #   @return [String]
          #     The URI for the artifact.
          class SignalArtifact; end

          # Describes whether the alerting condition is still firing.
          module State
            # Unspecified
            STATE_UNSPECIFIED = 0

            # Firing
            STATE_OPEN = 1

            # Non-firing
            STATE_CLOSED = 2
          end
        end

        # A text annotation by a user.
        # @!attribute [rw] name
        #   @return [String]
        #     Resource name of the annotation, for example,
        #     "projects/{project_id}/incidents/{incident_id}/annotations/{annotation_id}".
        # @!attribute [rw] author
        #   @return [Google::Cloud::Irm::V1alpha2::User]
        #     Output only. Author of the annotation.
        # @!attribute [rw] create_time
        #   @return [Google::Protobuf::Timestamp]
        #     Output only. Time the annotation was created.
        # @!attribute [rw] content
        #   @return [String]
        #     Content of the annotation. Immutable.
        # @!attribute [rw] content_type
        #   @return [String]
        #     Content type of the annotation, for example, 'text/plain'
        #     or 'text/markdown'. Immutable.
        class Annotation; end

        # A tag by a user.
        # @!attribute [rw] name
        #   @return [String]
        #     Resource name of a tag, for example,
        #     "projects/{project_id}/incidents/{incident_id}/tags/{tag_id}"
        # @!attribute [rw] display_name
        #   @return [String]
        #     Display name of the resource (for example, "cause:rollout"). Immutable.
        class Tag; end

        # Synopsis is a summary of an incident and it contains a textual content,
        # an author and a last updated timestamp.
        # @!attribute [rw] content_type
        #   @return [String]
        #     Content type string, for example, 'text/plain' or 'text/markdown'.
        # @!attribute [rw] content
        #   @return [String]
        #     Textual content of the synopsis. It can be plain text or markdown as
        #     indicated by the content_type.
        # @!attribute [rw] update_time
        #   @return [Google::Protobuf::Timestamp]
        #     Last updated timestamp.
        # @!attribute [rw] author
        #   @return [Google::Cloud::Irm::V1alpha2::User]
        #     Author of the synopsis.
        class Synopsis; end

        # Representation of an incident.
        # @!attribute [rw] name
        #   @return [String]
        #     Output only. Resource name of the incident, for example,
        #     "projects/{project_id}/incidents/{incident_id}".
        # @!attribute [rw] title
        #   @return [String]
        #     One-line summary of the incident.
        # @!attribute [rw] escalation_level
        #   @return [Google::Cloud::Irm::V1alpha2::Incident::EscalationLevel]
        #     Escalation level of the incident.
        # @!attribute [rw] etag
        #   @return [String]
        #     Etag to validate the object is unchanged for a read-modify-write operation.
        #     An empty etag will overwrite other changes.
        # @!attribute [rw] severity
        #   @return [Google::Cloud::Irm::V1alpha2::Incident::Severity]
        #     Severity of the incident.
        # @!attribute [rw] stage
        #   @return [Google::Cloud::Irm::V1alpha2::Incident::Stage]
        #     Stage of the incident.
        # @!attribute [rw] duplicate_incident
        #   @return [String]
        #     Resource name of the incident this incident is a duplicate of. Empty if
        #     this incident is not a duplicate.
        #     An incident can only be a duplicate of an incident that is not marked as a
        #     duplicate already. Setting this to a non-empty value must also set the
        #     stage to `STAGE_DUPLICATE`. Unsetting this value value must also update
        #     `stage` to a value other than `STAGE_DUPLICATE`.
        # @!attribute [rw] start_time
        #   @return [Google::Protobuf::Timestamp]
        #     Output only. Time this incident started. Used to measure the 'elapsed
        #     time'. Start time of an incident is the earliest creation time of any of
        #     its Signals or the create time of the incident if no Signals are assigned.
        # @!attribute [rw] synopsis
        #   @return [Google::Cloud::Irm::V1alpha2::Synopsis]
        #     Output only. Synopsis of this incident.
        # @!attribute [rw] communication_venue
        #   @return [Google::Cloud::Irm::V1alpha2::Incident::CommunicationVenue]
        #     Location of communications for this incident. This is informational
        #     only; IRM does not use this to send messages.
        class Incident
          # CommunicationVenue is a record of where conversations about an incident
          # are happening.
          # @!attribute [rw] uri
          #   @return [String]
          #     A URI to the web interface of the channel.
          # @!attribute [rw] display_name
          #   @return [String]
          #     A name representing the channel in IRM UI.
          # @!attribute [rw] channel_type
          #   @return [Google::Cloud::Irm::V1alpha2::Incident::CommunicationVenue::ChannelType]
          #     The type of channel/venue for incident communications.
          class CommunicationVenue
            # The type of channel/venue for incident communications.
            module ChannelType
              # An unspecified communication channel.
              CHANNEL_TYPE_UNSPECIFIED = 0

              # A communication channel that is represented by a generic URI.
              CHANNEL_TYPE_URI = 1

              # A communication channel that represents a Slack channel.
              CHANNEL_TYPE_SLACK = 5
            end
          end

          # Specifies the escalation level of this incident, within the IRM protocol
          # for handling incidents.
          module EscalationLevel
            # The incident has not been escalated. This is the value used by all new
            # and legacy incidents.
            ESCALATION_LEVEL_UNSPECIFIED = 0

            # The incident has been escalated to the organizational level.
            ESCALATION_LEVEL_ORGANIZATION = 1
          end

          # Severity of an incident.
          module Severity
            # Severity is not specified.
            SEVERITY_UNSPECIFIED = 0

            # Huge incident.
            SEVERITY_HUGE = 1

            # Major incident.
            SEVERITY_MAJOR = 2

            # Medium incident.
            SEVERITY_MEDIUM = 3

            # Minor incident.
            SEVERITY_MINOR = 4

            # Negligible incident.
            SEVERITY_NEGLIGIBLE = 5
          end

          # Stage of an incident.
          module Stage
            # This is the default value if no stage has been specified.
            # Note: The caller of the API should set the stage to DETECTED.
            STAGE_UNSPECIFIED = 0

            # The incident has been detected. This is the initial stage of a new
            # incident.
            # Note: The caller still has to set the stage manually.
            STAGE_DETECTED = 4

            # This incident has been formally characterized.
            STAGE_TRIAGED = 1

            # This incident has been mitigated, i.e. does not affect the service level
            # anymore.
            STAGE_MITIGATED = 2

            # This incident has been fully resolved, i.e. there are no immediate
            # follow-up tasks.
            STAGE_RESOLVED = 3

            # Postmortem for the incident was written.
            STAGE_DOCUMENTED = 5

            # Stage for an incident with `duplicate_incident`. This incident is not
            # authoritative anymore and the `duplicate_incident` should be used to
            # determine the stage.
            STAGE_DUPLICATE = 6
          end
        end

        # Describes a role that can be assigned to an incident.
        # @!attribute [rw] type
        #   @return [Google::Cloud::Irm::V1alpha2::IncidentRole::Type]
        #     The type of role. The role type is immutable in role assignments. Each role
        #     type can only be used once per incident, except for TYPE_OTHER.
        # @!attribute [rw] title
        #   @return [String]
        #     Output only unless TYPE_OTHER is used. Title of the role. For TYPE_OTHER,
        #     must be unique within an incident.
        # @!attribute [rw] description
        #   @return [String]
        #     Output only unless TYPE_OTHER is used. Description of the role.
        class IncidentRole
          # List of possible roles.
          module Type
            # The role is unspecified.
            TYPE_UNSPECIFIED = 0

            # Incident Commander: Manages response plan, near-term and long-term
            # objectives, establishes priorities, and delegates tasks as needed.
            TYPE_INCIDENT_COMMANDER = 1

            # Communications Lead: Keeps everybody outside and within the response team
            # informed.
            TYPE_COMMUNICATIONS_LEAD = 2

            # Operations Lead: Figures out what to do, and gets it done.
            TYPE_OPERATIONS_LEAD = 3

            # External Customer Communications Lead: Responsible for communicating
            # incident details to customers/public.
            TYPE_EXTERNAL_CUSTOMER_COMMUNICATIONS_LEAD = 4

            # Primary Oncall: Responds to the initial page and handles all
            # responsibilities for pre-escalated incidents.
            TYPE_PRIMARY_ONCALL = 5

            # Secondary Oncall: Helps the primary oncall if necessary; mostly useful
            # for pre-escalated incidents.
            TYPE_SECONDARY_ONCALL = 6

            # User-specified roles. One example is a Planning Lead, who keeps track of
            # the incident. Another is an assistant Incident Commander.
            TYPE_OTHER = 7
          end
        end

        # Stores the assignee of a role as well as the proposed next assignee.
        # @!attribute [rw] name
        #   @return [String]
        #     Output only. Resource name such as
        #     "projects/{project_id}/incidents/{incident_id}/role_assignments/{role_id}".
        # @!attribute [rw] etag
        #   @return [String]
        #     Output only. Etag for this version of the resource. Must be specified in
        #     update requests and match the current version in storage. Must not be
        #     modified by the client.
        # @!attribute [rw] role
        #   @return [Google::Cloud::Irm::V1alpha2::IncidentRole]
        #     The role that is or will be assigned.
        # @!attribute [rw] assignee
        #   @return [Google::Cloud::Irm::V1alpha2::User]
        #     The user this role is assigned to. This field can only be directly set
        #     during creation request. Subsequent updates are done via the
        #     IncidentRoleHandover methods.
        # @!attribute [rw] proposed_assignee
        #   @return [Google::Cloud::Irm::V1alpha2::User]
        #     The recipient of a requested role handoff. This field can only be directly
        #     set during creation request. Subsequent updates are done via the
        #     IncidentRoleHandover methods.
        #
        #     `assignee` is always the current role-holder, and `proposed_assignee` is
        #     used to track unfinished assignments and handoffs. Let's say Bob assigns
        #     Alice to a role. Then the fields are:
        #       `assignee`: nil, `proposed_assignee`: Alice
        #     If Alice accepts, then the fields are:
        #       `assignee`: Alice, `proposed_assignee`: nil
        #     If she cancels, then the RoleAssignment is deleted.
        #     Let's say Alice has the role. Then the fields are:
        #       `assignee`: Alice, `proposed_assignee`: nil
        #     If Alice becomes incapacitated and Bob requests Carol to take over, then
        #     the fields are:
        #       `assignee`: Alice, `proposed_assignee`: Carol
        #     After Carol accepts the handover, the fields are:
        #       `assignee`: Carol, `proposed_assignee`: nil
        #     Or if Carol refuses the handover, the fields are:
        #       `assignee`: Alice, `proposed_assignee`: nil
        class IncidentRoleAssignment; end

        # External artifact associated to an incident.
        # @!attribute [rw] name
        #   @return [String]
        #     Output only. Resource name such as
        #     "projects/{project_id}/incidents/{incident_id}/artifacts/{artifact_id}".
        # @!attribute [rw] display_name
        #   @return [String]
        #     User provided name of an artifact.
        # @!attribute [rw] etag
        #   @return [String]
        #     Output only. Etag for this version of the resource. Must be specified in
        #     update requests and match the current version in storage. Must not be
        #     modified by the client.
        # @!attribute [rw] url
        #   @return [String]
        #     URL to access the artifact.
        # @!attribute [rw] type
        #   @return [Google::Cloud::Irm::V1alpha2::Artifact::Type]
        #     Type of this artifact.
        class Artifact
          # Possible types of an artifact.
          module Type
            # External type is unspecified.
            TYPE_UNSPECIFIED = 0

            # URL.
            TYPE_URL = 1

            # A JIRA issue.
            TYPE_JIRA_ISSUE = 4
          end
        end

        # Communication Channels are mechanisms used to receive notifications
        # about changes to incidents.
        # @!attribute [rw] email
        #   @return [Google::Cloud::Irm::V1alpha2::CommunicationChannel::Email]
        #     Messages will be delivered via email.
        # @!attribute [rw] notification_channel
        #   @return [Google::Cloud::Irm::V1alpha2::CommunicationChannel::NotificationChannel]
        #     Messages will be delivered via a Stackdriver notification channel.
        class CommunicationChannel
          # A communication channel that delivers messages to an email address.
          # @!attribute [rw] address
          #   @return [String]
          #     The email address, for example, "user@example.com".
          class Email; end

          # A communication channel that delivers messages to a Stackdriver
          # notification channel.
          # @!attribute [rw] name
          #   @return [String]
          #     Stackdriver notification channel name.
          class NotificationChannel; end
        end

        # A subscription allows users to get notifications about changes to
        # an incident.
        # @!attribute [rw] name
        #   @return [String]
        #     Output only. Resource name such as
        #     "projects/{project_id}/incidents/{incident_id}/subscriptions/{subscription_id}".
        # @!attribute [rw] etag
        #   @return [String]
        #     Output only. Etag for this version of the resource. Must be specified in
        #     update requests and match the current version in storage. Must not be
        #     modified by the client.
        # @!attribute [rw] subscription_channel
        #   @return [Google::Cloud::Irm::V1alpha2::CommunicationChannel]
        #     A communications channel to send subscription messages to.
        # @!attribute [rw] event_types
        #   @return [Array<Google::Cloud::Irm::V1alpha2::Subscription::EventType>]
        #     Types of events this subscription receives notifications for.
        class Subscription
          # Types of changes that users can subscribe to in an incident.
          module EventType
            # An event_type that's not specified is an error.
            EVENT_TYPE_UNSPECIFIED = 0

            # The incident's title has changed.
            EVENT_TYPE_TITLE_CHANGE = 1

            # The incident's synopsis has changed.
            EVENT_TYPE_SYNOPSIS_CHANGE = 2

            # The incident's stage has changed.
            EVENT_TYPE_STAGE_CHANGE = 3

            # The incident's severity has changed.
            EVENT_TYPE_SEVERITY_CHANGE = 4

            # A new annotation has been added to the incident.
            EVENT_TYPE_ANNOTATION_ADD = 5

            # An annotation has been modified.
            EVENT_TYPE_ANNOTATION_CHANGE = 6
          end
        end
      end
    end
  end
end