// Copyright 2026 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.

syntax = "proto3";

package google.cloud.support.v2beta;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.Support.V2Beta";
option go_package = "cloud.google.com/go/support/apiv2beta/supportpb;supportpb";
option java_multiple_files = true;
option java_outer_classname = "SupportEventSubscriptionProto";
option java_package = "com.google.cloud.support.v2beta";
option php_namespace = "Google\\Cloud\\Support\\V2beta";
option ruby_package = "Google::Cloud::Support::V2beta";

// A support event subscription.
message SupportEventSubscription {
  option (google.api.resource) = {
    type: "cloudsupport.googleapis.com/SupportEventSubscription"
    pattern: "organizations/{organization}/supportEventSubscriptions/{support_event_subscription}"
    plural: "supportEventSubscriptions"
    singular: "supportEventSubscription"
  };

  // The state of the subscription.
  enum State {
    // Unspecified state.
    STATE_UNSPECIFIED = 0;

    // Subscription is active and working.
    WORKING = 1;

    // Subscription is failing. Notifications cannot be published for some
    // reason.
    FAILING = 2;

    // Subscription has been deleted and is pending purge. Notifications are not
    // sent for deleted subscriptions. Deleted subscriptions are purged after
    // their `purge_time` has passed.
    DELETED = 3;
  }

  // The reason why the subscription is failing.
  enum FailureReason {
    // Unspecified failure reason.
    FAILURE_REASON_UNSPECIFIED = 0;

    // The service account (i.e.
    // cloud-support-apievents@system.gserviceaccount.com) lacks the permission
    // to publish to the customer's Pub/Sub topic.
    PERMISSION_DENIED = 1;

    // The specified Pub/Sub topic does not exist.
    TOPIC_NOT_FOUND = 2;

    // Message failed to publish due to a system-side error.
    OTHER = 3;
  }

  // Identifier. The resource name of the support event subscription.
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. The name of the Pub/Sub topic to publish notifications to.
  // Format: projects/{project}/topics/{topic}
  string pub_sub_topic = 2 [(google.api.field_behavior) = REQUIRED];

  // Output only. The state of the subscription.
  State state = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Reason why subscription is failing. State of subscription
  // must be FAILING in order for this to have a value.
  FailureReason failure_reason = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the subscription was created.
  google.protobuf.Timestamp create_time = 5
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the subscription was last updated.
  google.protobuf.Timestamp update_time = 6
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the subscription was deleted.
  google.protobuf.Timestamp delete_time = 7
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time at which the subscription will be purged.
  google.protobuf.Timestamp purge_time = 8
      [(google.api.field_behavior) = OUTPUT_ONLY];
}
